diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-08-18 23:05:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-18 11:05:51 -0400 |
commit | 3c986ca524b6e9f0eb736d872748af7b479dd344 (patch) | |
tree | 34db52e3e76ba64d9e4eb6b72f78e80ffb5ffa27 | |
parent | 7766500bf591bbec460bd21dd69cf124a09ac691 (diff) |
test(cli): use assertThrowsAsync for permission tests (#7092)
-rw-r--r-- | cli/tests/unit/permissions_test.ts | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index 7528768a1..005727721 100644 --- a/cli/tests/unit/permissions_test.ts +++ b/cli/tests/unit/permissions_test.ts @@ -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); }); |