diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2022-09-29 17:38:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 17:38:04 +0200 |
commit | 927f4e2e83719aac3dcc4d9ae422cbbf76bd7bcd (patch) | |
tree | 9dc6dd8633471ca73ddc88941f4706b65c1a5b66 /cli/tests | |
parent | 15ea624790f2f96ba9d852f34d114d6c8329245a (diff) |
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.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/response_test.ts | 10 |
1 files changed, 10 insertions, 0 deletions
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); +}); |