diff --git a/apps/automated/src/timer/timer-tests.ts b/apps/automated/src/timer/timer-tests.ts index 17ad4e123..4f8f10bbb 100644 --- a/apps/automated/src/timer/timer-tests.ts +++ b/apps/automated/src/timer/timer-tests.ts @@ -188,6 +188,23 @@ export function test_setInterval_callbackNotDelayedByBusyWork() { TKUnit.assertEqual(calls, 2, 'Callback should be called multiple times with busy wait'); } +export function test_setInterval_callbackSkippedByBusyWork() { + let calls = 0; + + let firstCall = true; + const id = timer.setInterval(() => { + calls++; + if (firstCall) { + firstCall = false; + TKUnit.wait(0.051); + } + }, 50); + + TKUnit.wait(0.16); + timer.clearInterval(id); + TKUnit.assertEqual(calls, 2, 'Callback should be called skipped when it takes too long to process'); +} + export function test_setInterval_callbackShouldBeCleared(done) { const start = TKUnit.time(); // >> timer-set-interval