2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-03-04 11:31:14 -05:00
|
|
|
import { unitTest, assert } 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-02-21 10:36:13 -05:00
|
|
|
let thrown = false;
|
2019-10-27 11:22:53 -04:00
|
|
|
try {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
await Deno.permissions.query({ name: "foo" as any });
|
|
|
|
} catch (e) {
|
2020-02-21 10:36:13 -05:00
|
|
|
thrown = true;
|
|
|
|
assert(e instanceof Error);
|
|
|
|
} finally {
|
|
|
|
assert(thrown);
|
2019-10-27 11:22:53 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest(async function permissionNetInvalidUrl(): Promise<void> {
|
2020-02-21 10:36:13 -05:00
|
|
|
let thrown = false;
|
2019-10-27 11:22:53 -04:00
|
|
|
try {
|
|
|
|
await Deno.permissions.query({ name: "net", url: ":" });
|
|
|
|
} catch (e) {
|
2020-02-21 10:36:13 -05:00
|
|
|
thrown = true;
|
|
|
|
assert(e instanceof URIError);
|
|
|
|
} finally {
|
|
|
|
assert(thrown);
|
2019-10-27 11:22:53 -04:00
|
|
|
}
|
|
|
|
});
|