diff options
author | 2022-12-11 12:58:48 -0800 | |
---|---|---|
committer | 2022-12-11 12:58:48 -0800 | |
commit | b5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d (patch) | |
tree | 5d6f710f2b766a5b7346608bda1b8941559dbf4e /test/bun.js/console-iterator.test.js | |
parent | 9d94f148dca8aa683151845960f93521861a5d02 (diff) | |
download | bun-b5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d.tar.gz bun-b5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d.tar.zst bun-b5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d.zip |
cleanup some tests
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); }); } }); |