summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-08 17:46:15 +0800
committerGitHub <noreply@github.com>2020-09-08 11:46:15 +0200
commit1d0f1ed446acd2db7c052503570c9249e7b841e9 (patch)
tree96fd01ce451b48dc945df8d8237d4e30841c97d8 /cli/tests
parentc5d50737f05f6b1999d1973ba5bd260473aadcbd (diff)
fix: Empty Response body returns 0-byte array (#7387)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/fetch_test.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 012ce7b34..4bdb54d9e 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -738,6 +738,16 @@ unitTest(function responseRedirect(): void {
assertEquals(redir.type, "default");
});
+unitTest(async function responseWithoutBody(): Promise<void> {
+ const response = new Response();
+ assertEquals(await response.arrayBuffer(), new ArrayBuffer(0));
+ assertEquals(await response.blob(), new Blob([]));
+ assertEquals(await response.text(), "");
+ await assertThrowsAsync(async () => {
+ await response.json();
+ });
+});
+
unitTest({ perms: { net: true } }, async function fetchBodyReadTwice(): Promise<
void
> {