diff --git a/test/parallel/test-event-emitter-listeners.js b/test/parallel/test-event-emitter-listeners.js index cfb2dafb121e03..8aedd8fc3766bd 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(); @@ -49,3 +52,14 @@ function listener2() {} ee.once('foo', listener2); assert.deepStrictEqual(ee.listeners('foo'), [listener, listener2]); } + +{ + const ee = new events.EventEmitter(); + ee._events = undefined; + assert.deepStrictEqual(ee.listeners('foo'), []); +} + +{ + const s = new TestStream(); + assert.deepStrictEqual(s.listeners('foo'), []); +}