mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
test(cli): use assertThrowsAsync for permission tests (#7092)
This commit is contained in:
parent
7766500bf5
commit
3c986ca524
1 changed files with 5 additions and 17 deletions
|
@ -1,27 +1,15 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { unitTest, assert } from "./test_util.ts";
|
||||
import { unitTest, assertThrowsAsync } from "./test_util.ts";
|
||||
|
||||
unitTest(async function permissionInvalidName(): Promise<void> {
|
||||
let thrown = false;
|
||||
try {
|
||||
await assertThrowsAsync(async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await Deno.permissions.query({ name: "foo" as any });
|
||||
} catch (e) {
|
||||
thrown = true;
|
||||
assert(e instanceof Error);
|
||||
} finally {
|
||||
assert(thrown);
|
||||
}
|
||||
}, Error);
|
||||
});
|
||||
|
||||
unitTest(async function permissionNetInvalidUrl(): Promise<void> {
|
||||
let thrown = false;
|
||||
try {
|
||||
await assertThrowsAsync(async () => {
|
||||
await Deno.permissions.query({ name: "net", url: ":" });
|
||||
} catch (e) {
|
||||
thrown = true;
|
||||
assert(e instanceof URIError);
|
||||
} finally {
|
||||
assert(thrown);
|
||||
}
|
||||
}, URIError);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue