From 723c7c56dc13a53b802e4ccc3772686f03ca148f Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:58:37 -0700 Subject: Add `for await` --- test/bun.js/react-dom.test.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/bun.js/react-dom.test.tsx') 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(); + }); }); } } -- cgit v1.2.3