0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-domexception-cause.js
flakey5 00e5617533
lib: add cause to DOMException
PR-URL: https://github.com/nodejs/node/pull/44703
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-10-04 11:33:49 +00:00

34 lines
1.0 KiB
JavaScript

'use strict';
require('../common');
const { strictEqual, deepStrictEqual } = require('assert');
{
const domException = new DOMException('no cause', 'abc');
strictEqual(domException.name, 'abc');
strictEqual('cause' in domException, false);
strictEqual(domException.cause, undefined);
}
{
const domException = new DOMException('with undefined cause', { name: 'abc', cause: undefined });
strictEqual(domException.name, 'abc');
strictEqual('cause' in domException, true);
strictEqual(domException.cause, undefined);
}
{
const domException = new DOMException('with string cause', { name: 'abc', cause: 'foo' });
strictEqual(domException.name, 'abc');
strictEqual('cause' in domException, true);
strictEqual(domException.cause, 'foo');
}
{
const object = { reason: 'foo' };
const domException = new DOMException('with object cause', { name: 'abc', cause: object });
strictEqual(domException.name, 'abc');
strictEqual('cause' in domException, true);
deepStrictEqual(domException.cause, object);
}