Skip to content

Commit

Permalink
test: improve coverage on removeListeners functions
Browse files Browse the repository at this point in the history
PR-URL: #11140
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Italo A. Casas <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
matsuda-koushi authored and MylesBorins committed Mar 9, 2017
1 parent 34614af commit c161604
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-event-emitter-remove-all-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 8 additions & 0 deletions test/parallel/test-event-emitter-remove-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit c161604

Please sign in to comment.