2022-03-07 16:36:22 -05:00
|
|
|
import { assert, test } from '../run/test.setup.js'
|
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
|
|
|
test(() => {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
name: 'Includes structuredClone',
|
|
|
|
test() {
|
|
|
|
const target = {}
|
|
|
|
|
|
|
|
polyfill(target)
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-03-07 16:36:22 -05:00
|
|
|
assert.equal(Reflect.has(target, 'structuredClone'), true)
|
|
|
|
assert.equal(typeof target.structuredClone, 'function')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Supports structuredClone usage',
|
|
|
|
test() {
|
|
|
|
const target = {}
|
|
|
|
|
|
|
|
polyfill(target)
|
|
|
|
|
|
|
|
const obj = {
|
2022-03-07 16:37:50 -05:00
|
|
|
foo: 'bar',
|
2022-03-07 16:36:22 -05:00
|
|
|
baz: {
|
2022-03-07 16:37:50 -05:00
|
|
|
qux: 'quux',
|
2022-03-07 16:36:22 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const clone = target.structuredClone(obj)
|
|
|
|
|
|
|
|
assert.notEqual(obj, clone)
|
|
|
|
assert.notEqual(obj.baz, clone.baz)
|
|
|
|
|
|
|
|
assert.equal(obj.baz.qux, clone.baz.qux)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
})
|