-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #35991 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
1 parent
b7aa5e2
commit 567f8d8
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -636,4 +636,6 @@ module.exports = { | |
kNewListener, | ||
kTrustEvent, | ||
kRemoveListener, | ||
kEvents, | ||
isEventTarget, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const { | ||
deepStrictEqual, | ||
} = require('assert'); | ||
|
||
const { getEventListeners, EventEmitter } = require('events'); | ||
|
||
// Test getEventListeners on EventEmitter | ||
{ | ||
const fn1 = common.mustNotCall(); | ||
const fn2 = common.mustNotCall(); | ||
const emitter = new EventEmitter(); | ||
emitter.on('foo', fn1); | ||
emitter.on('foo', fn2); | ||
emitter.on('baz', fn1); | ||
emitter.on('baz', fn1); | ||
deepStrictEqual(getEventListeners(emitter, 'foo'), [fn1, fn2]); | ||
deepStrictEqual(getEventListeners(emitter, 'bar'), []); | ||
deepStrictEqual(getEventListeners(emitter, 'baz'), [fn1, fn1]); | ||
} | ||
// Test getEventListeners on EventTarget | ||
{ | ||
const fn1 = common.mustNotCall(); | ||
const fn2 = common.mustNotCall(); | ||
const target = new EventTarget(); | ||
target.addEventListener('foo', fn1); | ||
target.addEventListener('foo', fn2); | ||
target.addEventListener('baz', fn1); | ||
target.addEventListener('baz', fn1); | ||
deepStrictEqual(getEventListeners(target, 'foo'), [fn1, fn2]); | ||
deepStrictEqual(getEventListeners(target, 'bar'), []); | ||
deepStrictEqual(getEventListeners(target, 'baz'), [fn1]); | ||
} |