diff options
author | 2022-06-01 07:28:56 -0700 | |
---|---|---|
committer | 2022-06-01 07:28:56 -0700 | |
commit | f9710e270a5ced6abd3ddad634bb5d4829dcf5f3 (patch) | |
tree | 039ea3be8007bed9a91fab6f8867102c34e30bee /integration/bunjs-only-snippets | |
parent | 515da14621a85e6417adade07f6e776619991579 (diff) | |
download | bun-f9710e270a5ced6abd3ddad634bb5d4829dcf5f3.tar.gz bun-f9710e270a5ced6abd3ddad634bb5d4829dcf5f3.tar.zst bun-f9710e270a5ced6abd3ddad634bb5d4829dcf5f3.zip |
Update streams.test.js
Diffstat (limited to 'integration/bunjs-only-snippets')
-rw-r--r-- | integration/bunjs-only-snippets/streams.test.js | 22 |
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); +}); |