File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
lib/internal/test_runner/mock Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -711,10 +711,9 @@ class MockTimers {
711711 }
712712
713713 /**
714- * EnableOptions type:
715- * @typedef {object } EnableOptions
716- * @property {Array<string> } apis List of timers to enable, defaults to all
717- * @property {number|Date } now The epoch to which the timers should be set, defaults to 0
714+ * @typedef {{apis: SupportedApis;now: number | Date;} } EnableOptions Options to enable the timers
715+ * @property {SupportedApis } apis List of timers to enable, defaults to all
716+ * @property {number | Date } now The epoch to which the timers should be set to, defaults to 0
718717 */
719718
720719 /**
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- // eslint-disable-next-line no-unused-vars
4- const common = require ( '../common' ) ;
3+ require ( '../common' ) ;
54const assert = require ( 'assert' ) ;
6- const { MockTimers } = require ( 'internal/test_runner/mock/mock_timers' ) ;
7- const { AbortSignal } = require ( 'internal/abort_controller' ) ;
5+ const { mock } = require ( 'node:test' ) ;
86
97{
10- const mock = new MockTimers ( ) ;
11- mock . enable ( { apis : [ 'AbortSignal.timeout' ] } ) ;
8+ mock . timers . enable ( { apis : [ 'AbortSignal.timeout' ] } ) ;
129
1310 try {
1411 const signal = AbortSignal . timeout ( 50 ) ;
1512
1613 assert . strictEqual ( signal . aborted , false ) ;
1714
18- mock . tick ( 49 ) ;
15+ mock . timers . tick ( 49 ) ;
1916 assert . strictEqual ( signal . aborted , false ) ;
2017
21- mock . tick ( 1 ) ;
18+ mock . timers . tick ( 1 ) ;
2219 assert . strictEqual ( signal . aborted , true ) ;
2320 } finally {
24- mock . reset ( ) ;
21+ mock . timers . reset ( ) ;
2522 }
2623}
You can’t perform that action at this time.
0 commit comments