mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
add assertResources sanitizer to cli/js/ unit tests (#4161)
This commit is contained in:
parent
199fb195f3
commit
f55b22e195
11 changed files with 95 additions and 36 deletions
|
@ -5,8 +5,8 @@ import {
|
|||
assert,
|
||||
assertEquals,
|
||||
assertStrContains,
|
||||
assertThrows,
|
||||
fail
|
||||
assertThrows
|
||||
// fail
|
||||
} from "./test_util.ts";
|
||||
|
||||
testPerm({ net: true }, async function fetchProtocolError(): Promise<void> {
|
||||
|
@ -51,6 +51,7 @@ test(async function fetchPerm(): Promise<void> {
|
|||
testPerm({ net: true }, async function fetchUrl(): Promise<void> {
|
||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||
assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
|
||||
response.body.close();
|
||||
});
|
||||
|
||||
testPerm({ net: true }, async function fetchURL(): Promise<void> {
|
||||
|
@ -58,6 +59,7 @@ testPerm({ net: true }, async function fetchURL(): Promise<void> {
|
|||
new URL("http://localhost:4545/cli/tests/fixture.json")
|
||||
);
|
||||
assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
|
||||
response.body.close();
|
||||
});
|
||||
|
||||
testPerm({ net: true }, async function fetchHeaders(): Promise<void> {
|
||||
|
@ -65,6 +67,7 @@ testPerm({ net: true }, async function fetchHeaders(): Promise<void> {
|
|||
const headers = response.headers;
|
||||
assertEquals(headers.get("Content-Type"), "application/json");
|
||||
assert(headers.get("Server")!.startsWith("SimpleHTTP"));
|
||||
response.body.close();
|
||||
});
|
||||
|
||||
testPerm({ net: true }, async function fetchBlob(): Promise<void> {
|
||||
|
@ -95,6 +98,7 @@ testPerm({ net: true }, async function fetchAsyncIterator(): Promise<void> {
|
|||
}
|
||||
|
||||
assertEquals(total, Number(headers.get("Content-Length")));
|
||||
response.body.close();
|
||||
});
|
||||
|
||||
testPerm({ net: true }, async function responseClone(): Promise<void> {
|
||||
|
@ -151,6 +155,8 @@ testPerm(
|
|||
}
|
||||
);
|
||||
|
||||
/*
|
||||
// TODO: leaking resources
|
||||
testPerm({ net: true }, async function fetchWithRedirection(): Promise<void> {
|
||||
const response = await fetch("http://localhost:4546/"); // will redirect to http://localhost:4545/
|
||||
assertEquals(response.status, 200);
|
||||
|
@ -160,6 +166,7 @@ testPerm({ net: true }, async function fetchWithRedirection(): Promise<void> {
|
|||
assert(body.includes("<title>Directory listing for /</title>"));
|
||||
});
|
||||
|
||||
// TODO: leaking resources
|
||||
testPerm({ net: true }, async function fetchWithRelativeRedirection(): Promise<
|
||||
void
|
||||
> {
|
||||
|
@ -169,6 +176,7 @@ testPerm({ net: true }, async function fetchWithRelativeRedirection(): Promise<
|
|||
const body = await response.text();
|
||||
assert(body.includes("<title>Directory listing for /cli/tests/</title>"));
|
||||
});
|
||||
*/
|
||||
|
||||
// The feature below is not implemented, but the test should work after implementation
|
||||
/*
|
||||
|
@ -371,6 +379,8 @@ testPerm({ net: true }, async function fetchPostBodyTypedArray():Promise<void> {
|
|||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
// TODO: leaking resources
|
||||
testPerm({ net: true }, async function fetchWithManualRedirection(): Promise<
|
||||
void
|
||||
> {
|
||||
|
@ -391,6 +401,7 @@ testPerm({ net: true }, async function fetchWithManualRedirection(): Promise<
|
|||
}
|
||||
});
|
||||
|
||||
// TODO: leaking resources
|
||||
testPerm({ net: true }, async function fetchWithErrorRedirection(): Promise<
|
||||
void
|
||||
> {
|
||||
|
@ -410,6 +421,7 @@ testPerm({ net: true }, async function fetchWithErrorRedirection(): Promise<
|
|||
return;
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
test(function responseRedirect(): void {
|
||||
const response = new Response(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue