aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/child_process.test.ts8
-rw-r--r--test/bun.js/spawned-child.js12
2 files changed, 19 insertions, 1 deletions
diff --git a/test/bun.js/child_process.test.ts b/test/bun.js/child_process.test.ts
index fecc5b961..f39629169 100644
--- a/test/bun.js/child_process.test.ts
+++ b/test/bun.js/child_process.test.ts
@@ -259,6 +259,14 @@ describe("execFileSync()", () => {
const result = execFileSync("bun", ["-v"], { encoding: "utf8" });
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
+
+ it("should allow us to pass input to the command", () => {
+ const result = execFileSync("node", ["spawned-child.js", "STDIN"], {
+ input: "hello world!",
+ encoding: "utf8",
+ });
+ expect(result.trim()).toBe("hello world!");
+ });
});
describe("execSync()", () => {
diff --git a/test/bun.js/spawned-child.js b/test/bun.js/spawned-child.js
index 757aacd5c..c70aeab16 100644
--- a/test/bun.js/spawned-child.js
+++ b/test/bun.js/spawned-child.js
@@ -1 +1,11 @@
-setTimeout(() => console.log("hello"), 150);
+if (process.argv[2] === "STDIN") {
+ let result = "";
+ process.stdin.on("data", (data) => {
+ result += data;
+ });
+ process.stdin.on("close", () => {
+ console.log(result);
+ });
+} else {
+ setTimeout(() => console.log("hello"), 150);
+}