1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import { assert, test } from '../run/test.setup.js'
import { polyfill } from '../mod.js'
test(() => {
return [
{
name: 'Includes structuredClone',
test() {
const target = {}
polyfill(target)
assert.equal(Reflect.has(target, 'structuredClone'), true)
assert.equal(typeof target.structuredClone, 'function')
},
},
{
name: 'Supports structuredClone usage',
test() {
const target = {}
polyfill(target)
const obj = {
foo: "bar",
baz: {
qux: "quux",
},
}
const clone = target.structuredClone(obj)
assert.notEqual(obj, clone)
assert.notEqual(obj.baz, clone.baz)
assert.equal(obj.baz.qux, clone.baz.qux)
},
},
]
})
|