blob: 1abd84e1acc723e8ff7e2d6a0108e8e21446d67a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
'use strict';
require('../common');
const assert = require('assert');
const EventEmitter = require('events');
const eventsMethods = ['on', 'once', 'removeListener', 'prependOnceListener'];
// Verify that the listener must be a function for events methods
for (const method of eventsMethods) {
assert.throws(() => {
const ee = new EventEmitter();
ee[method]('foo', null);
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "listener" argument must be of type function. ' +
'Received null',
}, `event.${method}('foo', null) should throw the proper error`);
}
|