aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/console-iterator.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-11 12:58:48 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-11 12:58:48 -0800
commitb5519af7e7cc9e3812bdeb16d6f21f4a2b9c251d (patch)
tree5d6f710f2b766a5b7346608bda1b8941559dbf4e /test/bun.js/console-iterator.test.js
parent9d94f148dca8aa683151845960f93521861a5d02 (diff)
downloadbun-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.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);
});
}
});