Skip to content

Commit cd6b3be

Browse files
committed
test: Use TIMEOUT_MAX value for timer mocking test instead of hardcoded max integer
1 parent e32fa6a commit cd6b3be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/parallel/test-runner-mock-timers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --expose-internals
12
'use strict';
23
process.env.NODE_TEST_KNOWN_GLOBALS = 0;
34
const common = require('../common');
@@ -6,6 +7,7 @@ const assert = require('node:assert');
67
const { it, mock, describe } = require('node:test');
78
const nodeTimers = require('node:timers');
89
const nodeTimersPromises = require('node:timers/promises');
10+
const { TIMEOUT_MAX } = require('internal/timers');
911

1012
describe('Mock Timers Test Suite', () => {
1113
describe('MockTimers API', () => {
@@ -252,10 +254,10 @@ describe('Mock Timers Test Suite', () => {
252254
}), timeout);
253255
});
254256

255-
it('should change timeout to 1ms when it is >= 2 ** 31', (t) => {
257+
it('should change timeout to 1ms when it is > TIMEOUT_MAX', (t) => {
256258
t.mock.timers.enable({ apis: ['setTimeout'] });
257259
const fn = t.mock.fn();
258-
global.setTimeout(fn, 2 ** 31);
260+
global.setTimeout(fn, TIMEOUT_MAX + 1);
259261
t.mock.timers.tick(1);
260262
assert.strictEqual(fn.mock.callCount(), 1);
261263
});

0 commit comments

Comments
 (0)