-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve coverage of lib/events.js
PR-URL: #38582 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
- Loading branch information
1 parent
cd48ee7
commit b3b5995
Showing
2 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const EventEmitter = require('events'); | ||
|
||
// Test emit called by other context | ||
const EE = new EventEmitter(); | ||
|
||
// Works as expected if the context has no `constructor.name` | ||
{ | ||
const ctx = Object.create(null); | ||
assert.throws( | ||
() => EE.emit.call(ctx, 'error', new Error('foo')), | ||
common.expectsError({ name: 'Error', message: 'foo' }) | ||
); | ||
} | ||
|
||
assert.strictEqual(EE.emit.call({}, 'foo'), false); |
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