From 7d01a1eaca79164e4f5c65a6ded84d0d44918b3e Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Mon, 16 Nov 2020 14:14:39 -0300 Subject: [PATCH] skip callback test --- apps/automated/src/timer/timer-tests.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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