summaryrefslogtreecommitdiff
path: root/test/parallel/test-domexception-cause.js
diff options
context:
space:
mode:
authorflakey5 <73616808+flakey5@users.noreply.github.com>2022-10-04 04:33:49 -0700
committerGitHub <noreply@github.com>2022-10-04 11:33:49 +0000
commit00e5617533c29a6b0cfd9b5148604b441e8bd3b8 (patch)
treeb4b7e9d1d0dbebae0c7c666227b89c1d7e56e0db /test/parallel/test-domexception-cause.js
parentf594cc85b7dd80530dd65013da91c45c7b4a907d (diff)
downloadnode-new-00e5617533c29a6b0cfd9b5148604b441e8bd3b8.tar.gz
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>
Diffstat (limited to 'test/parallel/test-domexception-cause.js')
-rw-r--r--test/parallel/test-domexception-cause.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/parallel/test-domexception-cause.js b/test/parallel/test-domexception-cause.js
new file mode 100644
index 0000000000..179ef6d212
--- /dev/null
+++ b/test/parallel/test-domexception-cause.js
@@ -0,0 +1,33 @@
+'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);
+}