diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index 7528768a13..0057277212 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 { - 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 { - 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); });