X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Futils%2FUtils.test.ts;h=0ed7d6b67a54eea7d96aff3ed2a40c2675a99413;hb=8f801a9337304c521bf1ae125debe87405865fbf;hp=3622d8aec45cb0e80ad81381bf46af96b30b6362;hpb=cfab8dc9ea7801746461d4e8d6ac9852deb678b5;p=e-mobility-charging-stations-simulator.git diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 3622d8ae..0ed7d6b6 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -1,7 +1,9 @@ +import { version } from 'node:process' import { describe, it } from 'node:test' import { hoursToMilliseconds, hoursToSeconds } from 'date-fns' import { expect } from 'expect' +import { satisfies } from 'semver' import { Constants } from '../../src/utils/Constants.js' import { @@ -341,9 +343,10 @@ await describe('Utils test suite', async () => { const date = new Date() expect(clone(date)).toStrictEqual(date) expect(clone(date) === date).toBe(false) - // The URL object seems to have not enumerable properties - const url = new URL('https://domain.tld') - expect(clone(url)).toStrictEqual({}) + if (satisfies(version, '>=21.0.0')) { + const url = new URL('https://domain.tld') + expect(() => clone(url)).toThrowError(new Error('Cannot clone object of unsupported type.')) + } const map = new Map([['1', '2']]) expect(clone(map)).toStrictEqual(map) expect(clone(map) === map).toBe(false) @@ -351,9 +354,9 @@ await describe('Utils test suite', async () => { expect(clone(set)).toStrictEqual(set) expect(clone(set) === set).toBe(false) const weakMap = new WeakMap([[{ 1: 1 }, { 2: 2 }]]) - expect(() => clone(weakMap)).toThrow(new Error('# could not be cloned.')) + expect(() => clone(weakMap)).toThrowError(new Error('# could not be cloned.')) const weakSet = new WeakSet([{ 1: 1 }, { 2: 2 }]) - expect(() => clone(weakSet)).toThrow(new Error('# could not be cloned.')) + expect(() => clone(weakSet)).toThrowError(new Error('# could not be cloned.')) }) await it('Verify hasOwnProp()', () => {