From e4899b6ba417a801ce3d9128c9769e855487682f Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Wed, 8 Jul 2020 04:25:34 +0200 Subject: perf(cli/body): improve .arrayBuffer() speed (#6669) --- cli/tests/unit/fetch_test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (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 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 { + 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]; -- cgit v1.2.3