Browse Source

test: improve coverage on removeListeners functions

PR-URL: https://github.com/nodejs/node/pull/11140
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
v6.x
matsuda-koushi 8 years ago
committed by Myles Borins
parent
commit
c16160418b
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 11
      test/parallel/test-event-emitter-remove-all-listeners.js
  2. 8
      test/parallel/test-event-emitter-remove-listeners.js

11
test/parallel/test-event-emitter-remove-all-listeners.js

@ -77,3 +77,14 @@ function listener() {}
ee.removeAllListeners('baz');
assert.strictEqual(ee.listeners('baz').length, 0);
}
{
const ee = new events.EventEmitter();
assert.deepStrictEqual(ee, ee.removeAllListeners());
}
{
const ee = new events.EventEmitter();
ee._events = undefined;
assert.strictEqual(ee, ee.removeAllListeners());
}

8
test/parallel/test-event-emitter-remove-listeners.js

@ -122,3 +122,11 @@ assert.throws(() => {
ee.removeListener('foo', null);
}, /^TypeError: "listener" argument must be a function$/);
{
const ee = new EventEmitter();
const listener = () => {};
ee._events = undefined;
const e = ee.removeListener('foo', listener);
assert.strictEqual(e, ee);
}

Loading…
Cancel
Save