diff options
Diffstat (limited to 'packages/webapi/test/structuredclone.js')
-rw-r--r-- | packages/webapi/test/structuredclone.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/webapi/test/structuredclone.js b/packages/webapi/test/structuredclone.js new file mode 100644 index 000000000..6605f1f58 --- /dev/null +++ b/packages/webapi/test/structuredclone.js @@ -0,0 +1,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) + }, + }, + ] +}) |