From 927f4e2e83719aac3dcc4d9ae422cbbf76bd7bcd Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Thu, 29 Sep 2022 17:38:04 +0200 Subject: fix(ext/fetch): `Body#bodyUsed` for static body (#16080) This fixes a bug where `Body#bodyUsed` incorrectly returns `false` for a body that has actually already been consumed, after `Body#body` is called. --- cli/tests/unit/response_test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/response_test.ts b/cli/tests/unit/response_test.ts index c46218b62..c2a230138 100644 --- a/cli/tests/unit/response_test.ts +++ b/cli/tests/unit/response_test.ts @@ -90,3 +90,13 @@ Deno.test(function customInspectFunction() { ); assertStringIncludes(Deno.inspect(Response.prototype), "Response"); }); + +Deno.test(async function responseBodyUsed() { + const response = new Response("body"); + assert(!response.bodyUsed); + await response.text(); + assert(response.bodyUsed); + // .body getter is needed so we can test the faulty code path + response.body; + assert(response.bodyUsed); +}); -- cgit v1.2.3