diff options
Diffstat (limited to 'test/bun.js/console-iterator.test.js')
-rw-r--r-- | test/bun.js/console-iterator.test.js | 17 |
1 files changed, 9 insertions, 8 deletions
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); }); } }); |