-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixup] tests for events proxy, adjust based on results
- Loading branch information
1 parent
e07abd5
commit 88f0a14
Showing
2 changed files
with
53 additions
and
31 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const EventEmitter = require('events'); | ||
|
||
const _events = EventEmitter.prototype._events; | ||
|
||
const ee = new EventEmitter(); | ||
const noop = () => {}; | ||
|
||
assert.notStrictEqual(_events, ee._events); | ||
|
||
assert(!(ee._events instanceof Object)); | ||
assert.notStrictEqual(ee._events, undefined); | ||
assert.deepStrictEqual(Object.keys(ee._events), []); | ||
assert.strictEqual(ee._events.foo, undefined); | ||
assert.doesNotThrow(() => delete ee._events.foo); | ||
assert.strictEqual('foo' in ee._events, false); | ||
assert.strictEqual(Object.getOwnPropertyDescriptor(ee._events, 'foo'), | ||
undefined); | ||
|
||
assert.doesNotThrow(() => ee._events.foo = noop); | ||
|
||
assert.strictEqual(ee._events.foo, noop); | ||
assert.deepStrictEqual(Object.keys(ee._events), ['foo']); | ||
assert.deepStrictEqual(ee.listeners('foo'), [noop]); | ||
assert.strictEqual('foo' in ee._events, true); | ||
assert.deepStrictEqual(Object.getOwnPropertyDescriptor(ee._events, 'foo'), | ||
{ | ||
value: noop, | ||
writable: true, | ||
configurable: true, | ||
enumerable: true | ||
}); | ||
|
||
assert.doesNotThrow(() => delete ee._events.foo); | ||
assert.strictEqual(ee._events.foo, undefined); | ||
assert.deepStrictEqual(Object.keys(ee._events), []); | ||
assert.strictEqual('foo' in ee._events, false); | ||
assert.strictEqual(ee.listenerCount('foo'), 0); | ||
assert.strictEqual(Object.getOwnPropertyDescriptor(ee._events, 'foo'), | ||
undefined); |