summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/body_test.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/unit/body_test.ts b/cli/tests/unit/body_test.ts
index df824e1ae..d0423f7de 100644
--- a/cli/tests/unit/body_test.ts
+++ b/cli/tests/unit/body_test.ts
@@ -79,3 +79,26 @@ unitTest({ perms: {} }, async function bodyURLSearchParams(): Promise<void> {
const text = await body.text();
assertEquals(text, "hello=world");
});
+
+unitTest(async function bodyArrayBufferMultipleParts(): Promise<void> {
+ const parts: Uint8Array[] = [];
+ let size = 0;
+ for (let i = 0; i <= 150000; i++) {
+ const part = new Uint8Array([1]);
+ parts.push(part);
+ size += part.length;
+ }
+
+ let offset = 0;
+ const stream = new ReadableStream({
+ pull(controller): void {
+ // parts.shift() takes forever: https://github.com/denoland/deno/issues/5259
+ const chunk = parts[offset++];
+ if (!chunk) return controller.close();
+ controller.enqueue(chunk);
+ },
+ });
+
+ const body = buildBody(stream);
+ assertEquals((await body.arrayBuffer()).byteLength, size);
+});