From 84b921555fa481a0a2c4cffe5c897fd1c87485b7 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 28 Apr 2023 14:26:21 +0200 Subject: fix(ext/fetch): subview Uint8Array in Req/Resp (#18890) --- cli/tests/unit/fetch_test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index bafb23c2a..a92a7a051 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -1893,3 +1893,19 @@ Deno.test( await server; }, ); + +Deno.test("Request with subarray TypedArray body", async () => { + const body = new Uint8Array([1, 2, 3, 4, 5]).subarray(1); + const req = new Request("https://example.com", { method: "POST", body }); + const actual = new Uint8Array(await req.arrayBuffer()); + const expected = new Uint8Array([2, 3, 4, 5]); + assertEquals(actual, expected); +}); + +Deno.test("Response with subarray TypedArray body", async () => { + const body = new Uint8Array([1, 2, 3, 4, 5]).subarray(1); + const req = new Response(body); + const actual = new Uint8Array(await req.arrayBuffer()); + const expected = new Uint8Array([2, 3, 4, 5]); + assertEquals(actual, expected); +}); -- cgit v1.2.3