refactor: use native cloning function
[e-mobility-charging-stations-simulator.git] / tests / utils / Utils.test.ts
index 7bee08ac625850cb73f40819d8467f3c176e8b6e..3b2a52ae88d8b33911033f607155d0c3a89daaf3 100644 (file)
@@ -341,14 +341,17 @@ 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({})
     const map = new Map([['1', '2']])
-    expect(clone(map)).toStrictEqual({})
+    expect(clone(map)).toStrictEqual(map)
     const set = new Set(['1'])
-    expect(clone(set)).toStrictEqual({})
+    expect(clone(set)).toStrictEqual(set)
     const weakMap = new WeakMap([[{ 1: 1 }, { 2: 2 }]])
-    expect(clone(weakMap)).toStrictEqual({})
+    expect(() => clone(weakMap)).toThrow(new Error('#<WeakMap> could not be cloned.'))
     const weakSet = new WeakSet([{ 1: 1 }, { 2: 2 }])
-    expect(clone(weakSet)).toStrictEqual({})
+    expect(() => clone(weakSet)).toThrow(new Error('#<WeakSet> could not be cloned.'))
   })
 
   await it('Verify hasOwnProp()', () => {