diff options
Diffstat (limited to 'tests/unit/timers_test.ts')
-rw-r--r-- | tests/unit/timers_test.ts | 59 |
1 files changed, 3 insertions, 56 deletions
diff --git a/tests/unit/timers_test.ts b/tests/unit/timers_test.ts index 679e57df7..6e829c07f 100644 --- a/tests/unit/timers_test.ts +++ b/tests/unit/timers_test.ts @@ -4,7 +4,6 @@ import { assertEquals, assertNotEquals, delay, - DENO_FUTURE, execCode, unreachable, } from "./test_util.ts"; @@ -309,63 +308,11 @@ Deno.test(async function timeoutCallbackThis() { }; setTimeout(obj.foo, 1); await promise; - if (!DENO_FUTURE) { - assertEquals(capturedThis, window); - } else { - assertEquals(capturedThis, globalThis); - } -}); - -Deno.test({ ignore: DENO_FUTURE }, async function timeoutBindThis() { - const thisCheckPassed = [null, undefined, globalThis, window]; - - const thisCheckFailed = [ - 0, - "", - true, - false, - {}, - [], - "foo", - () => {}, - Object.prototype, - ]; - - for (const thisArg of thisCheckPassed) { - const { promise, resolve } = Promise.withResolvers<void>(); - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => resolve(), 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - await promise; - assertEquals(hasThrown, 1); - } - - for (const thisArg of thisCheckFailed) { - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => {}, 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - assertEquals(hasThrown, 2); - } + assertEquals(capturedThis, window); }); -Deno.test({ ignore: !DENO_FUTURE }, async function timeoutBindThis() { - const thisCheckPassed = [null, undefined, globalThis]; +Deno.test(async function timeoutBindThis() { + const thisCheckPassed = [null, undefined, window, globalThis]; const thisCheckFailed = [ 0, |