summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
authorYosi Pramajaya <yosi.pramajaya@gmail.com>2020-12-26 20:06:00 +0700
committerGitHub <noreply@github.com>2020-12-26 08:06:00 -0500
commitc1fdb30394ab336ec2e004d563be40180e218b0d (patch)
tree13352d292e08114300463ca02eb7b70b4efb88f5 /cli/tests/unit/fetch_test.ts
parentbfe1b053815f68b121691e9690b8353178d86128 (diff)
fix: fetch bad URL will not panic (#8884)
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts36
1 files changed, 32 insertions, 4 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 359a24e95..2355d0813 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -27,12 +27,37 @@ unitTest(
async (): Promise<void> => {
await fetch("http://localhost:4000");
},
- Deno.errors.Http,
+ TypeError,
"error trying to connect",
);
},
);
+unitTest(
+ { perms: { net: true } },
+ async function fetchDnsError(): Promise<void> {
+ await assertThrowsAsync(
+ async (): Promise<void> => {
+ await fetch("http://nil/");
+ },
+ TypeError,
+ "error trying to connect",
+ );
+ },
+);
+
+unitTest(
+ { perms: { net: true } },
+ async function fetchInvalidUriError(): Promise<void> {
+ await assertThrowsAsync(
+ async (): Promise<void> => {
+ await fetch("http://<invalid>/");
+ },
+ URIError,
+ );
+ },
+);
+
unitTest({ perms: { net: true } }, async function fetchJsonSuccess(): Promise<
void
> {
@@ -199,9 +224,12 @@ unitTest({ perms: { net: true } }, async function responseClone(): Promise<
unitTest({ perms: { net: true } }, async function fetchEmptyInvalid(): Promise<
void
> {
- await assertThrowsAsync(async () => {
- await fetch("");
- }, URIError);
+ await assertThrowsAsync(
+ async () => {
+ await fetch("");
+ },
+ URIError,
+ );
});
unitTest(