Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: better error validations for event-capture
  • Loading branch information
edsadr committed Apr 10, 2020
commit 3d4d51be5787602c7f28a5eed61546c40e8c5a00
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