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