Skip to content

Commit fb02de7

Browse files
test_runner: revert EnableOptions typedef change and update AbortSignal.timeout test
1 parent ef06137 commit fb02de7

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/internal/test_runner/mock/mock_timers.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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
/**
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
'use strict';
22

3-
// eslint-disable-next-line no-unused-vars
4-
const common = require('../common');
3+
require('../common');
54
const 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
}

0 commit comments

Comments
 (0)