Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: use timeout_max value for timer mocking test instead of hardcod…
…ed max integer
  • Loading branch information
badkeyy committed Oct 23, 2024
commit e0cbc878d2c63d067aa1a5b548b100075eaea6e1
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