mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test_runner: do not throw on mocked clearTimeout()
PR-URL: https://github.com/nodejs/node/pull/54005 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
parent
8c006d2d7a
commit
049c894350
@ -304,7 +304,7 @@ class MockTimers {
|
||||
}
|
||||
|
||||
#clearTimer(timer) {
|
||||
if (timer.priorityQueuePosition !== undefined) {
|
||||
if (timer?.priorityQueuePosition !== undefined) {
|
||||
this.#executionQueue.removeAt(timer.priorityQueuePosition);
|
||||
timer.priorityQueuePosition = undefined;
|
||||
}
|
||||
|
@ -257,6 +257,13 @@ describe('Mock Timers Test Suite', () => {
|
||||
|
||||
assert.strictEqual(fn.mock.callCount(), 0);
|
||||
});
|
||||
|
||||
it('clearTimeout does not throw on null and undefined', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
|
||||
nodeTimers.clearTimeout();
|
||||
nodeTimers.clearTimeout(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setInterval Suite', () => {
|
||||
@ -305,6 +312,13 @@ describe('Mock Timers Test Suite', () => {
|
||||
|
||||
assert.strictEqual(fn.mock.callCount(), 0);
|
||||
});
|
||||
|
||||
it('clearInterval does not throw on null and undefined', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setInterval'] });
|
||||
|
||||
nodeTimers.clearInterval();
|
||||
nodeTimers.clearInterval(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setImmediate Suite', () => {
|
||||
@ -372,6 +386,15 @@ describe('Mock Timers Test Suite', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('clearImmediate Suite', () => {
|
||||
it('clearImmediate does not throw on null and undefined', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setImmediate'] });
|
||||
|
||||
nodeTimers.clearImmediate();
|
||||
nodeTimers.clearImmediate(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('timers/promises', () => {
|
||||
describe('setTimeout Suite', () => {
|
||||
it('should advance in time and trigger timers when calling the .tick function multiple times', async (t) => {
|
||||
|
Loading…
Reference in New Issue
Block a user