diff options
author | 2022-05-18 04:50:07 -0700 | |
---|---|---|
committer | 2022-05-30 17:10:47 -0700 | |
commit | 4fb9354439ec9d8a03602eaa0a40f12f04d2a0ed (patch) | |
tree | 1d51eff0049d712d3a03f90de48f8d1dacbdba59 /integration/bunjs-only-snippets | |
parent | 958fc3d4f5ba2a1fb5b5e1e2b9fe3a4500dbefc6 (diff) | |
download | bun-4fb9354439ec9d8a03602eaa0a40f12f04d2a0ed.tar.gz bun-4fb9354439ec9d8a03602eaa0a40f12f04d2a0ed.tar.zst bun-4fb9354439ec9d8a03602eaa0a40f12f04d2a0ed.zip |
[bun.js] `WritableStream`, `ReadableStream`, `TransformStream`, `WritableStreamDefaultController`, `ReadableStreamDefaultController` & more
Diffstat (limited to 'integration/bunjs-only-snippets')
-rw-r--r-- | integration/bunjs-only-snippets/streams.test.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/streams.test.js b/integration/bunjs-only-snippets/streams.test.js new file mode 100644 index 000000000..f7998d248 --- /dev/null +++ b/integration/bunjs-only-snippets/streams.test.js @@ -0,0 +1,31 @@ +import { expect, it } from "bun:test"; + +it("exists globally", () => { + expect(typeof ReadableStream).toBe("function"); + expect(typeof ReadableStreamBYOBReader).toBe("function"); + expect(typeof ReadableStreamBYOBRequest).toBe("function"); + expect(typeof ReadableStreamDefaultController).toBe("function"); + expect(typeof ReadableStreamDefaultReader).toBe("function"); + expect(typeof TransformStream).toBe("function"); + expect(typeof TransformStreamDefaultController).toBe("function"); + expect(typeof WritableStream).toBe("function"); + expect(typeof WritableStreamDefaultController).toBe("function"); + expect(typeof WritableStreamDefaultWriter).toBe("function"); + expect(typeof ByteLengthQueuingStrategy).toBe("function"); + expect(typeof CountQueuingStrategy).toBe("function"); +}); + +it("ReadableStream", async () => { + var stream = new ReadableStream({ + start(controller) { + controller.enqueue(Buffer.from("abdefgh")); + }, + pull(controller) {}, + cancel() {}, + type: "bytes", + }); + const chunks = []; + const chunk = await stream.getReader().read(); + chunks.push(chunk.value); + expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join("")); +}); |