blob: f7998d2482c950f0440d3256f6fba98229b6de3d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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(""));
});
|