From 7d2dc90aeb7a7e05588b1623dd03be72970fa222 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/parallel/test-event-emitter-remove-all-listeners.js | 6 ++++++ test/parallel/test-event-emitter-remove-listeners.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js index d7865b09abe9f5..e793cedb0dd4cf 100644 --- a/test/parallel/test-event-emitter-remove-all-listeners.js +++ b/test/parallel/test-event-emitter-remove-all-listeners.js @@ -82,3 +82,9 @@ function listener() {} 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 03bde6c3d7c4c9..2253d20fef0c0b 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -128,3 +128,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); +}