aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-13 00:58:37 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-13 00:58:37 -0700
commit723c7c56dc13a53b802e4ccc3772686f03ca148f (patch)
treedf37c1894b23b7939a5d006f38cb5d7a7419fa5c
parent6b7a0c1d3fde32b6e3ded85456d0721c34aa9219 (diff)
downloadbun-723c7c56dc13a53b802e4ccc3772686f03ca148f.tar.gz
bun-723c7c56dc13a53b802e4ccc3772686f03ca148f.tar.zst
bun-723c7c56dc13a53b802e4ccc3772686f03ca148f.zip
Add `for await`
-rw-r--r--test/bun.js/react-dom.test.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/bun.js/react-dom.test.tsx b/test/bun.js/react-dom.test.tsx
index 42f4c7631..678f1ee9a 100644
--- a/test/bun.js/react-dom.test.tsx
+++ b/test/bun.js/react-dom.test.tsx
@@ -186,6 +186,33 @@ describe("ReactDOM", () => {
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
});
+ it("for await (chunk of stream)", async () => {
+ const stream = await renderToReadableStream(reactElement);
+ gc();
+ const chunks = [];
+ for await (let chunk of stream) {
+ chunks.push(chunk);
+ }
+ const text = await new Response(chunks).text();
+ gc();
+ expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
+ gc();
+ });
+
+ it("for await (chunk of stream) (arrayBuffer)", async () => {
+ const stream = await renderToReadableStream(reactElement);
+ gc();
+ const chunks = [];
+ for await (let chunk of stream) {
+ chunks.push(chunk);
+ }
+ const text = new TextDecoder().decode(
+ await new Response(chunks).arrayBuffer()
+ );
+ gc();
+ expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
+ gc();
+ });
});
}
}