Skip to content

Commit

Permalink
test: use timeout_max value for timer mocking test instead of hardcod…
Browse files Browse the repository at this point in the history
…ed max integer
  • Loading branch information
badkeyy committed Oct 23, 2024
1 parent 78cb2e5 commit e0cbc87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/parallel/test-runner-mock-timers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';
process.env.NODE_TEST_KNOWN_GLOBALS = 0;
const common = require('../common');
Expand All @@ -6,6 +7,7 @@ const assert = require('node:assert');
const { it, mock, describe } = require('node:test');
const nodeTimers = require('node:timers');
const nodeTimersPromises = require('node:timers/promises');
const { TIMEOUT_MAX } = require('internal/timers');

describe('Mock Timers Test Suite', () => {
describe('MockTimers API', () => {
Expand Down Expand Up @@ -252,10 +254,10 @@ describe('Mock Timers Test Suite', () => {
}), timeout);
});

it('should change timeout to 1ms when it is >= 2 ** 31', (t) => {
it('should change timeout to 1ms when it is > TIMEOUT_MAX', (t) => {
t.mock.timers.enable({ apis: ['setTimeout'] });
const fn = t.mock.fn();
global.setTimeout(fn, 2 ** 31);
global.setTimeout(fn, TIMEOUT_MAX + 1);
t.mock.timers.tick(1);
assert.strictEqual(fn.mock.callCount(), 1);
});
Expand Down

0 comments on commit e0cbc87

Please sign in to comment.