mirror of
https://github.com/nodejs/node.git
synced 2025-05-12 18:03:44 +00:00

fixup PR-URL: https://github.com/nodejs/node/pull/50398 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
assert.throws(() => structuredClone(), { code: 'ERR_MISSING_ARGS' });
|
|
assert.throws(() => structuredClone(undefined, ''), { code: 'ERR_INVALID_ARG_TYPE' });
|
|
assert.throws(() => structuredClone(undefined, 1), { code: 'ERR_INVALID_ARG_TYPE' });
|
|
assert.throws(() => structuredClone(undefined, { transfer: 1 }), { code: 'ERR_INVALID_ARG_TYPE' });
|
|
assert.throws(() => structuredClone(undefined, { transfer: '' }), { code: 'ERR_INVALID_ARG_TYPE' });
|
|
|
|
// Options can be null or undefined.
|
|
assert.strictEqual(structuredClone(undefined), undefined);
|
|
assert.strictEqual(structuredClone(undefined, null), undefined);
|
|
// Transfer can be null or undefined.
|
|
assert.strictEqual(structuredClone(undefined, { transfer: null }), undefined);
|
|
assert.strictEqual(structuredClone(undefined, { }), undefined);
|
|
|
|
{
|
|
// See: https://github.com/nodejs/node/issues/49940
|
|
const cloned = structuredClone({}, {
|
|
transfer: {
|
|
*[Symbol.iterator]() {}
|
|
}
|
|
});
|
|
|
|
assert.deepStrictEqual(cloned, {});
|
|
}
|