summaryrefslogtreecommitdiff
path: root/cli/js/tests/fetch_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/tests/fetch_test.ts')
-rw-r--r--cli/js/tests/fetch_test.ts58
1 files changed, 29 insertions, 29 deletions
diff --git a/cli/js/tests/fetch_test.ts b/cli/js/tests/fetch_test.ts
index 67675177e..432ecd59c 100644
--- a/cli/js/tests/fetch_test.ts
+++ b/cli/js/tests/fetch_test.ts
@@ -5,7 +5,7 @@ import {
assertEquals,
assertStrContains,
assertThrows,
- fail
+ fail,
} from "./test_util.ts";
unitTest({ perms: { net: true } }, async function fetchProtocolError(): Promise<
@@ -174,7 +174,7 @@ unitTest(
unitTest(
{
- perms: { net: true }
+ perms: { net: true },
},
async function fetchWithRedirection(): Promise<void> {
const response = await fetch("http://localhost:4546/"); // will redirect to http://localhost:4545/
@@ -188,7 +188,7 @@ unitTest(
unitTest(
{
- perms: { net: true }
+ perms: { net: true },
},
async function fetchWithRelativeRedirection(): Promise<void> {
const response = await fetch("http://localhost:4545/cli/tests"); // will redirect to /cli/tests/
@@ -204,7 +204,7 @@ unitTest(
// FIXME(bartlomieju):
// The feature below is not implemented, but the test should work after implementation
ignore: true,
- perms: { net: true }
+ perms: { net: true },
},
async function fetchWithInfRedirection(): Promise<void> {
const response = await fetch("http://localhost:4549/cli/tests"); // will redirect to the same place
@@ -218,7 +218,7 @@ unitTest(
const data = "Hello World";
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: data
+ body: data,
});
const text = await response.text();
assertEquals(text, data);
@@ -232,7 +232,7 @@ unitTest(
const data = "Hello World";
const req = new Request("http://localhost:4545/echo_server", {
method: "POST",
- body: data
+ body: data,
});
const response = await fetch(req);
const text = await response.text();
@@ -246,7 +246,7 @@ unitTest(
const data = "Hello World";
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: new TextEncoder().encode(data)
+ body: new TextEncoder().encode(data),
});
const text = await response.text();
assertEquals(text, data);
@@ -260,7 +260,7 @@ unitTest(
const params = new URLSearchParams(data);
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: params
+ body: params,
});
const text = await response.text();
assertEquals(text, data);
@@ -277,11 +277,11 @@ unitTest({ perms: { net: true } }, async function fetchInitBlobBody(): Promise<
> {
const data = "const a = 1";
const blob = new Blob([data], {
- type: "text/javascript"
+ type: "text/javascript",
});
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: blob
+ body: blob,
});
const text = await response.text();
assertEquals(text, data);
@@ -295,7 +295,7 @@ unitTest(
form.append("field", "value");
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: form
+ body: form,
});
const resultForm = await response.formData();
assertEquals(form.get("field"), resultForm.get("field"));
@@ -308,7 +308,7 @@ unitTest({ perms: { net: true } }, async function fetchUserAgent(): Promise<
const data = "Hello World";
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
- body: new TextEncoder().encode(data)
+ body: new TextEncoder().encode(data),
});
assertEquals(response.headers.get("user-agent"), `Deno/${Deno.version.deno}`);
await response.text();
@@ -337,7 +337,7 @@ function bufferServer(addr: string): Deno.Buffer {
const [hostname, port] = addr.split(":");
const listener = Deno.listen({
hostname,
- port: Number(port)
+ port: Number(port),
}) as Deno.Listener;
const buf = new Deno.Buffer();
listener.accept().then(async (conn: Deno.Conn) => {
@@ -364,7 +364,7 @@ unitTest(
{
// FIXME(bartlomieju)
ignore: true,
- perms: { net: true }
+ perms: { net: true },
},
async function fetchRequest(): Promise<void> {
const addr = "127.0.0.1:4501";
@@ -373,8 +373,8 @@ unitTest(
method: "POST",
headers: [
["Hello", "World"],
- ["Foo", "Bar"]
- ]
+ ["Foo", "Bar"],
+ ],
});
assertEquals(response.status, 404);
assertEquals(response.headers.get("Content-Length"), "2");
@@ -384,7 +384,7 @@ unitTest(
"POST /blah HTTP/1.1\r\n",
"hello: World\r\n",
"foo: Bar\r\n",
- `host: ${addr}\r\n\r\n`
+ `host: ${addr}\r\n\r\n`,
].join("");
assertEquals(actual, expected);
}
@@ -394,7 +394,7 @@ unitTest(
{
// FIXME(bartlomieju)
ignore: true,
- perms: { net: true }
+ perms: { net: true },
},
async function fetchPostBodyString(): Promise<void> {
const addr = "127.0.0.1:4502";
@@ -404,9 +404,9 @@ unitTest(
method: "POST",
headers: [
["Hello", "World"],
- ["Foo", "Bar"]
+ ["Foo", "Bar"],
],
- body
+ body,
});
assertEquals(response.status, 404);
assertEquals(response.headers.get("Content-Length"), "2");
@@ -418,7 +418,7 @@ unitTest(
"foo: Bar\r\n",
`host: ${addr}\r\n`,
`content-length: ${body.length}\r\n\r\n`,
- body
+ body,
].join("");
assertEquals(actual, expected);
}
@@ -428,7 +428,7 @@ unitTest(
{
// FIXME(bartlomieju)
ignore: true,
- perms: { net: true }
+ perms: { net: true },
},
async function fetchPostBodyTypedArray(): Promise<void> {
const addr = "127.0.0.1:4503";
@@ -439,9 +439,9 @@ unitTest(
method: "POST",
headers: [
["Hello", "World"],
- ["Foo", "Bar"]
+ ["Foo", "Bar"],
],
- body
+ body,
});
assertEquals(response.status, 404);
assertEquals(response.headers.get("Content-Length"), "2");
@@ -453,7 +453,7 @@ unitTest(
"foo: Bar\r\n",
`host: ${addr}\r\n`,
`content-length: ${body.byteLength}\r\n\r\n`,
- bodyStr
+ bodyStr,
].join("");
assertEquals(actual, expected);
}
@@ -461,11 +461,11 @@ unitTest(
unitTest(
{
- perms: { net: true }
+ perms: { net: true },
},
async function fetchWithManualRedirection(): Promise<void> {
const response = await fetch("http://localhost:4546/", {
- redirect: "manual"
+ redirect: "manual",
}); // will redirect to http://localhost:4545/
assertEquals(response.status, 0);
assertEquals(response.statusText, "");
@@ -484,11 +484,11 @@ unitTest(
unitTest(
{
- perms: { net: true }
+ perms: { net: true },
},
async function fetchWithErrorRedirection(): Promise<void> {
const response = await fetch("http://localhost:4546/", {
- redirect: "error"
+ redirect: "error",
}); // will redirect to http://localhost:4545/
assertEquals(response.status, 0);
assertEquals(response.statusText, "");