diff --git a/test/parallel/test-event-emitter-listeners.js b/test/parallel/test-event-emitter-listeners.js index dfd66287b194a7..11c1ed49824cd2 100644 --- a/test/parallel/test-event-emitter-listeners.js +++ b/test/parallel/test-event-emitter-listeners.js @@ -3,9 +3,12 @@ require('../common'); const assert = require('assert'); const events = require('events'); +const util = require('util'); function listener() {} function listener2() {} +class TestStream { constructor() { } } +util.inherits(TestStream, events.EventEmitter); { const ee = new events.EventEmitter(); @@ -36,3 +39,14 @@ function listener2() {} assert.deepStrictEqual(ee.listeners('foo'), [listener, listener2]); assert.deepStrictEqual(eeListenersCopy, [listener]); } + +{ + const ee = new events.EventEmitter(); + ee._events = undefined; + assert.deepStrictEqual(ee.listeners('foo'), []); +} + +{ + const s = new TestStream(); + assert.deepStrictEqual(s.listeners('foo'), []); +}