diff options
| author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2020-07-13 18:23:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-13 18:23:24 +0200 |
| commit | 11560387bb056098c55049db22c63550358c953a (patch) | |
| tree | eb3a4704c2ee7f2ae36a035833e1b1962a594ba0 /cli/tests/unit/permissions_test.ts | |
| parent | 44187c81f4a09dbec0ca83b91e5f378590c93cff (diff) | |
Revert "feat: move unstable Deno.permissions to navigator.permissions… (#6729)
* Revert "feat: move unstable Deno.permissions to navigator.permissions (#6244)"
This reverts commit 202e7fa6ad366ee56a6d070e94eaecb6dbc745bf.
Diffstat (limited to 'cli/tests/unit/permissions_test.ts')
| -rw-r--r-- | cli/tests/unit/permissions_test.ts | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index 0de6a774b..7528768a1 100644 --- a/cli/tests/unit/permissions_test.ts +++ b/cli/tests/unit/permissions_test.ts @@ -1,40 +1,27 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -import { unitTest, assert, assertThrowsAsync } from "./test_util.ts"; +import { unitTest, assert } from "./test_util.ts"; unitTest(async function permissionInvalidName(): Promise<void> { - await assertThrowsAsync(async () => { - // @ts-expect-error name should not accept "foo" - await navigator.permissions.query({ name: "foo" }); - }, TypeError); + let thrown = false; + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await Deno.permissions.query({ name: "foo" as any }); + } catch (e) { + thrown = true; + assert(e instanceof Error); + } finally { + assert(thrown); + } }); unitTest(async function permissionNetInvalidUrl(): Promise<void> { - await assertThrowsAsync(async () => { - await navigator.permissions.query({ name: "net", url: ":" }); - }, URIError); -}); - -unitTest(async function permissionQueryReturnsEventTarget(): Promise<void> { - const status = await navigator.permissions.query({ name: "hrtime" }); - assert(["granted", "denied", "prompt"].includes(status.state)); - let called = false; - status.addEventListener("change", () => { - called = true; - }); - status.dispatchEvent(new Event("change")); - assert(called); - assert(status === (await navigator.permissions.query({ name: "hrtime" }))); -}); - -unitTest(async function permissionQueryForReadReturnsSameStatus() { - const status1 = await navigator.permissions.query({ - name: "read", - path: ".", - }); - const status2 = await navigator.permissions.query({ - name: "read", - path: ".", - }); - assert(status1 === status2); + let thrown = false; + try { + await Deno.permissions.query({ name: "net", url: ":" }); + } catch (e) { + thrown = true; + assert(e instanceof URIError); + } finally { + assert(thrown); + } }); |
