GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: do not throw on mocked clearTimeout() · nodejs/node@edd80e2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/test_runner/mock
    • mock_timers.js
  • test/parallel
    • test-runner-mock-timers.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/mock/mock_timers.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/mock/mock_timers.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class MockTimers {
304304
}
305305

306306
#clearTimer(timer) {
307-
if (timer.priorityQueuePosition !== undefined) {
307+
if (timer?.priorityQueuePosition !== undefined) {
308308
this.#executionQueue.removeAt(timer.priorityQueuePosition);
309309
timer.priorityQueuePosition = undefined;
310310
}
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-runner-mock-timers.js
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ describe('Mock Timers Test Suite', () => {
257257

258258
assert.strictEqual(fn.mock.callCount(), 0);
259259
});
260+
261+
it('clearTimeout does not throw on null and undefined', (t) => {
262+
t.mock.timers.enable({ apis: ['setTimeout'] });
263+
264+
nodeTimers.clearTimeout();
265+
nodeTimers.clearTimeout(null);
266+
});
260267
});
261268

262269
describe('setInterval Suite', () => {
@@ -305,6 +312,13 @@ describe('Mock Timers Test Suite', () => {
305312

306313
assert.strictEqual(fn.mock.callCount(), 0);
307314
});
315+
316+
it('clearInterval does not throw on null and undefined', (t) => {
317+
t.mock.timers.enable({ apis: ['setInterval'] });
318+
319+
nodeTimers.clearInterval();
320+
nodeTimers.clearInterval(null);
321+
});
308322
});
309323

310324
describe('setImmediate Suite', () => {
@@ -372,6 +386,15 @@ describe('Mock Timers Test Suite', () => {
372386
});
373387
});
374388

389+
describe('clearImmediate Suite', () => {
390+
it('clearImmediate does not throw on null and undefined', (t) => {
391+
t.mock.timers.enable({ apis: ['setImmediate'] });
392+
393+
nodeTimers.clearImmediate();
394+
nodeTimers.clearImmediate(null);
395+
});
396+
});
397+
375398
describe('timers/promises', () => {
376399
describe('setTimeout Suite', () => {
377400
it('should advance in time and trigger timers when calling the .tick function multiple times', async (t) => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.