mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
d5d7a416c7
As much as I would like to do this everywhere and then modify the lint rule to enforce it, the churn would be too big. However if we're going to have relatively frequent nits for this sort of thing (as we do), I'd prefer we migrate a few files at a time to never actually getting around to doing it. Ref: https://github.com/nodejs/node/pull/45448#pullrequestreview-1179370442 PR-URL: https://github.com/nodejs/node/pull/45466 Reviewed-By: James M Snell <jasnell@gmail.com>
21 lines
616 B
JavaScript
21 lines
616 B
JavaScript
'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`);
|
|
}
|