File tree Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
const common = require ( '../common' ) ;
3
- const { once } = require ( 'events' ) ;
4
-
5
- const et = new EventTarget ( ) ;
6
- ( async function ( ) {
7
- await once ( et , 'foo' ) ;
8
- await once ( et , 'foo' ) ;
9
- } ) ( ) . then ( common . mustCall ( ) ) ;
10
-
11
- et . dispatchEvent ( new Event ( 'foo' ) ) ;
12
- setImmediate ( ( ) => {
13
- et . dispatchEvent ( new Event ( 'foo' ) ) ;
14
- } ) ;
3
+ const assert = require ( 'node:assert/strict' ) ;
4
+ const { once } = require ( 'node:events' ) ;
5
+ const { test } = require ( 'node:test' ) ;
6
+ const { setImmediate } = require ( 'node:timers/promises' ) ;
7
+
8
+ test ( 'should resolve `once` twice' , ( t , done ) => {
9
+
10
+ const et = new EventTarget ( ) ;
11
+
12
+ ( async ( ) => {
13
+ await once ( et , 'foo' ) ;
14
+ await once ( et , 'foo' ) ;
15
+ done ( ) ;
16
+ } ) ( ) ;
17
+
18
+ ( async ( ) => {
19
+ et . dispatchEvent ( new Event ( 'foo' ) ) ;
20
+ await setImmediate ( ) ;
21
+ et . dispatchEvent ( new Event ( 'foo' ) ) ;
22
+ } ) ( ) ;
23
+
24
+ } ) ;
You can’t perform that action at this time.
0 commit comments