Update streams.test.js

This commit is contained in:
Jarred Sumner
2022-05-20 15:40:39 -07:00
committed by Jarred Sumner
parent 3e55023819
commit ab2d25bfec

View File

@@ -29,3 +29,18 @@ it("ReadableStream", async () => {
chunks.push(chunk.value);
expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join(""));
});
it("ReadableStream for Blob", async () => {
var blob = new Blob(["abdefgh", "ijklmnop"]);
var stream = blob.stream();
const chunks = [];
var reader = stream.getReader();
while (true) {
const chunk = await reader.read();
if (chunk.done) break;
chunks.push(chunk.value);
}
expect(chunks.map((a) => a.join("")).join("")).toBe(
Buffer.from("abdefghijklmnop").join("")
);
});