-
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: use test runner in eventtarget-once-twice test
Signed-off-by: Alexander “weej” Jones <[email protected]>
- Loading branch information
Showing
1 changed file
with
22 additions
and
12 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 |
---|---|---|
@@ -1,14 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { once } = require('events'); | ||
|
||
const et = new EventTarget(); | ||
(async function() { | ||
await once(et, 'foo'); | ||
await once(et, 'foo'); | ||
})().then(common.mustCall()); | ||
|
||
et.dispatchEvent(new Event('foo')); | ||
setImmediate(() => { | ||
et.dispatchEvent(new Event('foo')); | ||
}); | ||
const assert = require('node:assert/strict'); | ||
const { once } = require('node:events'); | ||
const { test } = require('node:test'); | ||
const { setImmediate } = require('node:timers/promises'); | ||
|
||
test('should resolve `once` twice', (t, done) => { | ||
|
||
const et = new EventTarget(); | ||
|
||
(async () => { | ||
await once(et, 'foo'); | ||
await once(et, 'foo'); | ||
done(); | ||
})(); | ||
|
||
(async () => { | ||
et.dispatchEvent(new Event('foo')); | ||
await setImmediate(); | ||
et.dispatchEvent(new Event('foo')); | ||
})(); | ||
|
||
}); |