2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-09-27 06:22:32 -04:00
|
|
|
import { assertThrows, assertThrowsAsync, unitTest } from "./test_util.ts";
|
2019-10-27 11:22:53 -04:00
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest(async function permissionInvalidName(): Promise<void> {
|
2020-08-18 11:05:51 -04:00
|
|
|
await assertThrowsAsync(async () => {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-07-13 12:23:24 -04:00
|
|
|
await Deno.permissions.query({ name: "foo" as any });
|
2020-08-18 11:05:51 -04:00
|
|
|
}, Error);
|
2019-10-27 11:22:53 -04:00
|
|
|
});
|
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest(async function permissionNetInvalidUrl(): Promise<void> {
|
2020-08-18 11:05:51 -04:00
|
|
|
await assertThrowsAsync(async () => {
|
2020-07-13 12:23:24 -04:00
|
|
|
await Deno.permissions.query({ name: "net", url: ":" });
|
2020-08-18 11:05:51 -04:00
|
|
|
}, URIError);
|
2019-10-27 11:22:53 -04:00
|
|
|
});
|
2020-09-19 17:30:59 -04:00
|
|
|
|
|
|
|
unitTest(function permissionsIllegalConstructor() {
|
|
|
|
assertThrows(() => new Deno.Permissions(), TypeError, "Illegal constructor.");
|
|
|
|
});
|
|
|
|
|
|
|
|
unitTest(function permissionStatusIllegalConstructor() {
|
|
|
|
assertThrows(
|
|
|
|
() => new Deno.PermissionStatus(),
|
|
|
|
TypeError,
|
|
|
|
"Illegal constructor.",
|
|
|
|
);
|
|
|
|
});
|