2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-02-28 09:47:54 -05:00
|
|
|
import { test, assert } from "./test_util.ts";
|
2019-10-27 11:22:53 -04:00
|
|
|
|
|
|
|
test(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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test(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
|
|
|
}
|
|
|
|
});
|