From 20692f3e844816d7d4a4f4fdfbfe30e416822350 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Wed, 22 Sep 2021 21:21:11 +0800 Subject: chore: replace calls to assertThrowsAsync with assertRejects (#12176) --- cli/tests/unit/fetch_test.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'cli/tests/unit/fetch_test.ts') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index c26718d02..a1609c775 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -2,7 +2,7 @@ import { assert, assertEquals, - assertThrowsAsync, + assertRejects, deferred, fail, unimplemented, @@ -13,7 +13,7 @@ import { Buffer } from "../../../test_util/std/io/buffer.ts"; unitTest( { perms: { net: true } }, async function fetchRequiresOneArgument() { - await assertThrowsAsync( + await assertRejects( fetch as unknown as () => Promise, TypeError, ); @@ -21,7 +21,7 @@ unitTest( ); unitTest({ perms: { net: true } }, async function fetchProtocolError() { - await assertThrowsAsync( + await assertRejects( async () => { await fetch("file:///"); }, @@ -58,7 +58,7 @@ unitTest( { perms: { net: true } }, async function fetchConnectionError() { const port = findClosedPortInRange(4000, 9999); - await assertThrowsAsync( + await assertRejects( async () => { await fetch(`http://localhost:${port}`); }, @@ -71,7 +71,7 @@ unitTest( unitTest( { perms: { net: true } }, async function fetchDnsError() { - await assertThrowsAsync( + await assertRejects( async () => { await fetch("http://nil/"); }, @@ -84,7 +84,7 @@ unitTest( unitTest( { perms: { net: true } }, async function fetchInvalidUriError() { - await assertThrowsAsync( + await assertRejects( async () => { await fetch("http:///"); }, @@ -100,7 +100,7 @@ unitTest({ perms: { net: true } }, async function fetchJsonSuccess() { }); unitTest(async function fetchPerm() { - await assertThrowsAsync(async () => { + await assertRejects(async () => { await fetch("http://localhost:4545/fixture.json"); }, Deno.errors.PermissionDenied); }); @@ -258,7 +258,7 @@ unitTest( ); assert(response.body !== null); - await assertThrowsAsync( + await assertRejects( async () => { await response.formData(); }, @@ -410,7 +410,7 @@ unitTest( perms: { net: true }, }, async function fetchWithInfRedirection() { - await assertThrowsAsync( + await assertRejects( () => fetch("http://localhost:4549"), TypeError, "redirect", @@ -760,7 +760,7 @@ unitTest( perms: { net: true }, }, async function fetchWithErrorRedirection() { - await assertThrowsAsync( + await assertRejects( () => fetch("http://localhost:4546/", { redirect: "error", @@ -790,7 +790,7 @@ unitTest(async function responseWithoutBody() { assertEquals(blob.size, 0); assertEquals(await blob.arrayBuffer(), new ArrayBuffer(0)); assertEquals(await response.text(), ""); - await assertThrowsAsync(async () => { + await assertRejects(async () => { await response.json(); }); }); @@ -1176,7 +1176,7 @@ unitTest( }, }); const nonExistantHostname = "http://localhost:47582"; - await assertThrowsAsync(async () => { + await assertRejects(async () => { await fetch(nonExistantHostname, { body, method: "POST" }); }, TypeError); await done; @@ -1196,7 +1196,7 @@ unitTest( unitTest( { perms: { read: true, net: true } }, async function fetchClientCertWrongPrivateKey(): Promise { - await assertThrowsAsync(async () => { + await assertRejects(async () => { const client = Deno.createHttpClient({ certChain: "bad data", privateKey: await Deno.readTextFile( @@ -1213,7 +1213,7 @@ unitTest( unitTest( { perms: { read: true, net: true } }, async function fetchClientCertBadPrivateKey(): Promise { - await assertThrowsAsync(async () => { + await assertRejects(async () => { const client = Deno.createHttpClient({ certChain: await Deno.readTextFile( "cli/tests/testdata/tls/localhost.crt", @@ -1230,7 +1230,7 @@ unitTest( unitTest( { perms: { read: true, net: true } }, async function fetchClientCertNotPrivateKey(): Promise { - await assertThrowsAsync(async () => { + await assertRejects(async () => { const client = Deno.createHttpClient({ certChain: await Deno.readTextFile( "cli/tests/testdata/tls/localhost.crt", -- cgit v1.2.3