summaryrefslogtreecommitdiff
path: root/js/permissions_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/permissions_test.ts')
-rw-r--r--js/permissions_test.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/permissions_test.ts b/js/permissions_test.ts
new file mode 100644
index 000000000..f4245c03b
--- /dev/null
+++ b/js/permissions_test.ts
@@ -0,0 +1,22 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+import { testPerm, assert, assertEqual } from "./test_util.ts";
+import { Permission } from "deno";
+
+const knownPermissions: Permission[] = ["run", "read", "write", "net", "env"];
+
+for (let grant of knownPermissions) {
+ testPerm({ [grant]: true }, function envGranted() {
+ const perms = Deno.permissions();
+ assert(perms !== null);
+ for (const perm in perms) {
+ assertEqual(perms[perm], perm === grant);
+ }
+
+ Deno.revokePermission(grant);
+
+ const revoked = Deno.permissions();
+ for (const perm in revoked) {
+ assertEqual(revoked[perm], false);
+ }
+ });
+}