deno.land / std@0.224.0 / permissions / test.ts

View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { grant, grantOrThrow } from "./mod.ts";import { assert, assertEquals, assertRejects } from "../assert/mod.ts";
Deno.test({ name: "grant basic", async fn() { assertEquals(await grant({ name: "net" }, { name: "env" }), [ { name: "net" }, { name: "env" }, ]); },});
Deno.test({ name: "grant array", async fn() { assertEquals(await grant([{ name: "net" }, { name: "env" }]), [ { name: "net" }, { name: "env" }, ]); },});
Deno.test({ name: "grant logic", async fn() { assert(await grant({ name: "net" })); },});
Deno.test({ name: "grantOrThrow basic", async fn() { await grantOrThrow({ name: "net" }, { name: "env" }); },});
Deno.test({ name: "grantOrThrow array", async fn() { await grantOrThrow([{ name: "net" }, { name: "env" }]); },});
Deno.test({ name: "grantOrThrow invalid argument", async fn() { await assertRejects( () => { return grantOrThrow(); }, TypeError, `The provided value "undefined" is not a valid permission name.`, ); },});
Deno.test({ name: "grantOrThrow invalid permissionDescriptor name", async fn() { await assertRejects( () => { // deno-lint-ignore no-explicit-any return grantOrThrow({ name: "nett" } as any); }, TypeError, 'The provided value "nett" is not a valid permission name', ); },});
// TODO(wafuwafu13): Add denied case
std

Version Info

Tagged at
6 months ago