diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-03-10 01:06:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 01:06:47 +0100 |
commit | 68119e1d7ed23421ccdcba20532ebe9ae3df9f18 (patch) | |
tree | 455dd170024112e3388adc27ebebb119b0ecda38 /cli/js/globals_test.ts | |
parent | dad8036766dca3417b79858b9a04d90447f88605 (diff) |
reorg: move js runtime tests to cli/js/tests/ (#4250)
All Deno runtime test files were moved to cli/js/tests/ directory.
It makes a clear distinction that cli/js/tests/ contains code
that is run under Deno runtime as opposed to code in cli/js/ which
is used to create bundle and snapshot with "deno_typescript".
Diffstat (limited to 'cli/js/globals_test.ts')
-rw-r--r-- | cli/js/globals_test.ts | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/cli/js/globals_test.ts b/cli/js/globals_test.ts deleted file mode 100644 index aa8b4f46e..000000000 --- a/cli/js/globals_test.ts +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { unitTest, assert } from "./test_util.ts"; - -unitTest(function globalThisExists(): void { - assert(globalThis != null); -}); - -unitTest(function windowExists(): void { - assert(window != null); -}); - -unitTest(function selfExists(): void { - assert(self != null); -}); - -unitTest(function windowWindowExists(): void { - assert(window.window === window); -}); - -unitTest(function windowSelfExists(): void { - assert(window.self === window); -}); - -unitTest(function globalThisEqualsWindow(): void { - assert(globalThis === window); -}); - -unitTest(function globalThisEqualsSelf(): void { - assert(globalThis === self); -}); - -unitTest(function DenoNamespaceExists(): void { - assert(Deno != null); -}); - -unitTest(function DenoNamespaceEqualsWindowDeno(): void { - assert(Deno === window.Deno); -}); - -unitTest(function DenoNamespaceIsFrozen(): void { - assert(Object.isFrozen(Deno)); -}); - -unitTest(function webAssemblyExists(): void { - assert(typeof WebAssembly.compile === "function"); -}); - -unitTest(function DenoNamespaceImmutable(): void { - const denoCopy = window.Deno; - try { - // @ts-ignore - Deno = 1; - } catch {} - assert(denoCopy === Deno); - try { - // @ts-ignore - window.Deno = 1; - } catch {} - assert(denoCopy === Deno); - try { - delete window.Deno; - } catch {} - assert(denoCopy === Deno); - - const { readFile } = Deno; - try { - // @ts-ignore - Deno.readFile = 1; - } catch {} - assert(readFile === Deno.readFile); - try { - delete window.Deno.readFile; - } catch {} - assert(readFile === Deno.readFile); - - // @ts-ignore - const { print } = Deno.core; - try { - // @ts-ignore - Deno.core.print = 1; - } catch {} - // @ts-ignore - assert(print === Deno.core.print); - try { - // @ts-ignore - delete Deno.core.print; - } catch {} - // @ts-ignore - assert(print === Deno.core.print); -}); - -unitTest(async function windowQueueMicrotask(): Promise<void> { - let resolve1: () => void | undefined; - let resolve2: () => void | undefined; - let microtaskDone = false; - const p1 = new Promise((res): void => { - resolve1 = (): void => { - microtaskDone = true; - res(); - }; - }); - const p2 = new Promise((res): void => { - resolve2 = (): void => { - assert(microtaskDone); - res(); - }; - }); - window.queueMicrotask(resolve1!); - setTimeout(resolve2!, 0); - await p1; - await p2; -}); |