aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/console-iterator.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/console-iterator.test.js')
-rw-r--r--test/bun.js/console-iterator.test.js17
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);
});
}
});