mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: better error validations for event-capture
PR-URL: https://github.com/nodejs/node/pull/32771 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
1 parent
7e9f88e005
commit
988c2fe287
1 file changed
+10
-2
@@ -278,14 +278,22 @@ function resetCaptureOnThrowInError() {
|
||||
function argValidation() {
|
||||
|
||||
function testType(obj) {
|
||||
const received = obj.constructor.name !== 'Number' ?
|
||||
`an instance of ${obj.constructor.name}` :
|
||||
`type number (${obj})`;
|
||||
|
||||
assert.throws(() => new EventEmitter({ captureRejections: obj }), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError'
|
||||
name: 'TypeError',
|
||||
message: 'The "options.captureRejections" property must be of type ' +
|
||||
`boolean. Received ${received}`
|
||||
});
|
||||
|
||||
assert.throws(() => EventEmitter.captureRejections = obj, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError'
|
||||
name: 'TypeError',
|
||||
message: 'The "EventEmitter.captureRejections" property must be of ' +
|
||||
`type boolean. Received ${received}`
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user