1
0
Fork 0
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:
Casper Beyer 2020-08-18 23:05:51 +08:00 committed by GitHub
parent 7766500bf5
commit 3c986ca524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
});