forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: nodejs#44703 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
- Loading branch information
Showing
2 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |