Skip to content

Commit

Permalink
test: better error validations for event-capture
Browse files Browse the repository at this point in the history
PR-URL: #32771
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
edsadr authored and targos committed Apr 30, 2020
1 parent f32cda2 commit bda62f0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/parallel/test-event-capture-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
});
}

Expand Down

0 comments on commit bda62f0

Please sign in to comment.