From b5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 11 Dec 2022 12:58:48 -0800 Subject: cleanup some tests --- test/bun.js/console-iterator.test.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'test/bun.js/console-iterator.test.js') diff --git a/test/bun.js/console-iterator.test.js b/test/bun.js/console-iterator.test.js index c211fe8e6..533f084e1 100644 --- a/test/bun.js/console-iterator.test.js +++ b/test/bun.js/console-iterator.test.js @@ -10,7 +10,7 @@ describe("should work for static input", () => { "hello world\n\n\n", "Hello\nWorld\n", "1", - "❤️ Red Heart ✨ Sparkles 🔥 Fire\n❤️ Red Heart ✨ Sparkles\n❤️ Red Heart\n❤️\n\nnormal", + "💕 Red Heart ✨ Sparkles 🔥 Fire\n💕 Red Heart ✨ Sparkles\n💕 Red Heart\n💕\n\nnormal", ]; for (let input of inputs) { @@ -35,12 +35,12 @@ describe("should work for streaming input", () => { "hello world\n\n\n", "Hello\nWorld\n", "1", - "❤️ Red Heart ✨ Sparkles 🔥 Fire\n❤️ Red Heart ✨ Sparkles\n❤️ Red Heart\n❤️\n\nnormal", + "💕 Red Heart ✨ Sparkles 🔥 Fire\n 💕 Red Heart ✨ Sparkles\n 💕 Red Heart\n 💕 \n\nnormal", ]; for (let input of inputs) { it(input.replaceAll("\n", "\\n"), async () => { - const { stdout, stdin } = spawn({ + const proc = spawn({ cmd: [bunExe(), import.meta.dir + "/" + "console-iterator-run.js"], stdin: "pipe", stdout: "pipe", @@ -48,17 +48,18 @@ describe("should work for streaming input", () => { BUN_DEBUG_QUIET_LOGS: "1", }, }); - stdin.write(input.slice(0, 4)); - await new Promise((resolve) => setTimeout(resolve, 1)); - stdin.write(input.slice(4, 5)); - await new Promise((resolve) => setTimeout(resolve, 1)); - stdin.write(input.slice(5)); + const { stdout, stdin } = proc; + stdin.write(input.slice(0, (input.length / 2) | 0)); + stdin.flush(); await new Promise((resolve) => setTimeout(resolve, 1)); + stdin.write(input.slice((input.length / 2) | 0)); + stdin.flush(); stdin.end(); expect(await new Response(stdout).text()).toBe( input.replaceAll("\n", ""), ); + proc.kill(0); }); } }); -- cgit v1.2.3