@@ -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