aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/process-stdio.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-04 02:53:04 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-04 02:53:04 -0800
commitf052e66df538f7fabb0e173d9dd79888201286f2 (patch)
tree336fec084318b8cb93f48b85185c662d7e5b226b /test/bun.js/process-stdio.test.ts
parent46e34a3fa9cba38e70ba034e5ea45584ecce5960 (diff)
downloadbun-f052e66df538f7fabb0e173d9dd79888201286f2.tar.gz
bun-f052e66df538f7fabb0e173d9dd79888201286f2.tar.zst
bun-f052e66df538f7fabb0e173d9dd79888201286f2.zip
Add some basic tests for process.stdout
Diffstat (limited to 'test/bun.js/process-stdio.test.ts')
-rw-r--r--test/bun.js/process-stdio.test.ts69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/bun.js/process-stdio.test.ts b/test/bun.js/process-stdio.test.ts
new file mode 100644
index 000000000..886bf9dac
--- /dev/null
+++ b/test/bun.js/process-stdio.test.ts
@@ -0,0 +1,69 @@
+import { spawnSync } from "bun";
+import { describe, expect, it, test } from "bun:test";
+import { bunExe } from "bunExe";
+import { isatty } from "tty";
+
+test("process.stdout", () => {
+ expect(process.stdout).toBeDefined();
+ expect(process.stdout.isTTY).toBe(isatty(1));
+});
+
+test("process.stderr", () => {
+ expect(process.stderr).toBeDefined();
+ expect(process.stderr.isTTY).toBe(isatty(2));
+});
+
+test("process.stdout - write", () => {
+ const { stdout } = spawnSync({
+ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance.js"],
+ stdout: "pipe",
+ stdin: null,
+ stderr: null,
+ env: {
+ ...process.env,
+ BUN_DEBUG_QUIET_LOGS: "1",
+ },
+ });
+
+ expect(stdout?.toString()).toBe(
+ `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`,
+ );
+});
+
+test("process.stdout - write a lot (string)", () => {
+ const { stdout } = spawnSync({
+ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance-a-lot.js"],
+ stdout: "pipe",
+ stdin: null,
+ stderr: null,
+ env: {
+ ...process.env,
+ BUN_DEBUG_QUIET_LOGS: "1",
+ TEST_STDIO_STRING: "1",
+ },
+ });
+
+ expect(stdout?.toString()).toBe(
+ `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(
+ 9999,
+ ),
+ );
+});
+
+test("process.stdout - write a lot (bytes)", () => {
+ const { stdout } = spawnSync({
+ cmd: [bunExe(), import.meta.dir + "/stdio-test-instance-a-lot.js"],
+ stdout: "pipe",
+ stdin: null,
+ stderr: null,
+ env: {
+ ...process.env,
+ BUN_DEBUG_QUIET_LOGS: "1",
+ },
+ });
+ expect(stdout?.toString()).toBe(
+ `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(
+ 9999,
+ ),
+ );
+});