diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-02-28 15:47:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 15:47:54 +0100 |
commit | a13b0e27279e54205adb53cdaf2415c825e77714 (patch) | |
tree | f108a6b2d0755cc435c7e19d2e38b8f6b8405328 /cli/js | |
parent | 7255cc9bc089e1257c2119e4c8a089c0b4970e64 (diff) |
rewrite permission revoke test as integration test (#4164)
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/permissions_test.ts | 31 | ||||
-rw-r--r-- | cli/js/unit_tests.ts | 6 |
2 files changed, 2 insertions, 35 deletions
diff --git a/cli/js/permissions_test.ts b/cli/js/permissions_test.ts index 6d79cfec0..7a36ee901 100644 --- a/cli/js/permissions_test.ts +++ b/cli/js/permissions_test.ts @@ -1,34 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEquals } from "./test_util.ts"; - -const knownPermissions: Deno.PermissionName[] = [ - "run", - "read", - "write", - "net", - "env", - "plugin", - "hrtime" -]; - -function genFunc(grant: Deno.PermissionName): () => Promise<void> { - const gen: () => Promise<void> = async function Granted(): Promise<void> { - const status0 = await Deno.permissions.query({ name: grant }); - assert(status0 != null); - assertEquals(status0.state, "granted"); - - const status1 = await Deno.permissions.revoke({ name: grant }); - assert(status1 != null); - assertEquals(status1.state, "prompt"); - }; - // Properly name these generated functions. - Object.defineProperty(gen, "name", { value: grant + "Granted" }); - return gen; -} - -for (const grant of knownPermissions) { - testPerm({ [grant]: true }, genFunc(grant)); -} +import { test, assert } from "./test_util.ts"; test(async function permissionInvalidName(): Promise<void> { let thrown = false; diff --git a/cli/js/unit_tests.ts b/cli/js/unit_tests.ts index 2495c938b..f20e2f137 100644 --- a/cli/js/unit_tests.ts +++ b/cli/js/unit_tests.ts @@ -37,6 +37,7 @@ import "./mixins/dom_iterable_test.ts"; import "./mkdir_test.ts"; import "./net_test.ts"; import "./os_test.ts"; +import "./permissions_test.ts"; import "./process_test.ts"; import "./realpath_test.ts"; import "./read_dir_test.ts"; @@ -63,11 +64,6 @@ import "./performance_test.ts"; import "./version_test.ts"; import "./workers_test.ts"; -// FIXME(bartlomieju): -// This test file revokes permissions, it must be run last, -// otherwise it might revoke permission for tests that need them. -import "./permissions_test.ts"; - if (import.meta.main) { await Deno.runTests(); } |