From c16160418b30e6616bf7b9a3efd83dc419e5b5f5 Mon Sep 17 00:00:00 2001 From: matsuda-koushi Date: Fri, 3 Feb 2017 15:59:12 +0900 Subject: [PATCH] test: improve coverage on removeListeners functions PR-URL: https://github.com/nodejs/node/pull/11140 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Italo A. Casas Reviewed-By: Michael Dawson --- .../test-event-emitter-remove-all-listeners.js | 11 +++++++++++ test/parallel/test-event-emitter-remove-listeners.js | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js index e32a0e3f94f5b4..1970904df25a75 100644 --- a/test/parallel/test-event-emitter-remove-all-listeners.js +++ b/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()); +} diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index ff5ee5dc242e0f..55108f753c7a15 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/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); +}