2022-04-10 20:29:46 -05:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 16:36:22 -05:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
describe('structuredClone', () => {
|
|
|
|
const target = {}
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
it('Includes structuredClone', () => {
|
|
|
|
expect(target).to.have.property('structuredClone').that.is.a('function')
|
|
|
|
})
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
it('Supports structuredClone usage', () => {
|
|
|
|
const obj = {
|
|
|
|
foo: 'bar',
|
|
|
|
baz: {
|
|
|
|
qux: 'quux',
|
|
|
|
},
|
|
|
|
}
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
const clone = target.structuredClone(obj)
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
expect(obj).to.not.equal(clone)
|
|
|
|
expect(obj.baz).to.not.equal(clone.baz)
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
expect(obj.baz.qux).to.equal(clone.baz.qux)
|
|
|
|
})
|
2022-03-07 16:36:22 -05:00
|
|
|
})
|