diff options
author | 2022-10-13 00:58:37 -0700 | |
---|---|---|
committer | 2022-10-13 00:58:37 -0700 | |
commit | 723c7c56dc13a53b802e4ccc3772686f03ca148f (patch) | |
tree | df37c1894b23b7939a5d006f38cb5d7a7419fa5c | |
parent | 6b7a0c1d3fde32b6e3ded85456d0721c34aa9219 (diff) | |
download | bun-723c7c56dc13a53b802e4ccc3772686f03ca148f.tar.gz bun-723c7c56dc13a53b802e4ccc3772686f03ca148f.tar.zst bun-723c7c56dc13a53b802e4ccc3772686f03ca148f.zip |
Add `for await`
-rw-r--r-- | test/bun.js/react-dom.test.tsx | 27 |
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(); + }); }); } } |