diff options
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index f8ceebf6e..84f2c2822 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -851,6 +851,25 @@ unitTest( } ); +unitTest( + { perms: { net: true } }, + async function fetchResponseContentLength(): Promise<void> { + const body = new Uint8Array(2 ** 16); + const headers = new Headers([["content-type", "application/octet-stream"]]); + const res = await fetch("http://localhost:4545/echo_server", { + body: body, + method: "POST", + headers, + }); + assertEquals(Number(res.headers.get("content-length")), body.byteLength); + + const blob = await res.blob(); + // Make sure Body content-type is correctly set + assertEquals(blob.type, "application/octet-stream"); + assertEquals(blob.size, body.byteLength); + } +); + unitTest(function fetchResponseConstructorNullBody(): void { const nullBodyStatus = [204, 205, 304]; |