| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,7 +301,7 @@ class MockTimers { | |||
| 301 | 301 | } | |
| 302 | 302 | ||
| 303 | 303 | #clearTimer(timer) { | |
| 304 | - if (timer.priorityQueuePosition !== undefined) { | ||
| 304 | + if (timer?.priorityQueuePosition !== undefined) { | ||
| 305 | 305 | this.#executionQueue.removeAt(timer.priorityQueuePosition); | |
| 306 | 306 | timer.priorityQueuePosition = undefined; | |
| 307 | 307 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -257,6 +257,13 @@ describe('Mock Timers Test Suite', () => { | |||
| 257 | 257 | ||
| 258 | 258 | assert.strictEqual(fn.mock.callCount(), 0); | |
| 259 | 259 | }); | |
| 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 | + }); | ||
| 260 | 267 | }); | |
| 261 | 268 | ||
| 262 | 269 | describe('setInterval Suite', () => { | |
@@ -305,6 +312,13 @@ describe('Mock Timers Test Suite', () => { | |||
| 305 | 312 | ||
| 306 | 313 | assert.strictEqual(fn.mock.callCount(), 0); | |
| 307 | 314 | }); | |
| 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 | + }); | ||
| 308 | 322 | }); | |
| 309 | 323 | ||
| 310 | 324 | describe('setImmediate Suite', () => { | |
@@ -372,6 +386,15 @@ describe('Mock Timers Test Suite', () => { | |||
| 372 | 386 | }); | |
| 373 | 387 | }); | |
| 374 | 388 | ||
| 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 | + | ||
| 375 | 398 | describe('timers/promises', () => { | |
| 376 | 399 | describe('setTimeout Suite', () => { | |
| 377 | 400 | it('should advance in time and trigger timers when calling the .tick function multiple times', async (t) => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments