aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets
diff options
context:
space:
mode:
Diffstat (limited to 'integration/bunjs-only-snippets')
-rw-r--r--integration/bunjs-only-snippets/streams.test.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/streams.test.js b/integration/bunjs-only-snippets/streams.test.js
index f5b84fd9d..f43413997 100644
--- a/integration/bunjs-only-snippets/streams.test.js
+++ b/integration/bunjs-only-snippets/streams.test.js
@@ -1,3 +1,4 @@
+import { file, gc } from "bun";
import { expect, it } from "bun:test";
it("exists globally", () => {
@@ -44,3 +45,24 @@ it("ReadableStream for Blob", async () => {
Buffer.from("abdefghijklmnop").join("")
);
});
+
+it("ReadableStream for File", async () => {
+ var blob = file(import.meta.dir + "/fetch.js.txt");
+ var stream = blob.stream(24);
+ const chunks = [];
+ var reader = stream.getReader();
+ stream = undefined;
+
+ while (true) {
+ const chunk = await reader.read();
+ gc(true);
+ if (chunk.done) break;
+ chunks.push(chunk.value);
+ gc(true);
+ }
+ reader = undefined;
+ expect(chunks.map((a) => a.join("")).join("")).toBe(
+ new Uint8Array(await blob.arrayBuffer()).join("")
+ );
+ gc(true);
+});