From 3c986ca524b6e9f0eb736d872748af7b479dd344 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 18 Aug 2020 23:05:51 +0800 Subject: [PATCH] test(cli): use assertThrowsAsync for permission tests (#7092) --- cli/tests/unit/permissions_test.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) 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); });