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