blob: 7e052fa6de785ac9142a307ffe18c360f7386c1e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import path from "path";
import { bunExe, bunEnv } from "harness";
test("works with prompts", async () => {
var child = Bun.spawn({
cmd: [bunExe(), path.join(import.meta.dir, "prompts.js")],
env: bunEnv,
stdout: "pipe",
stdin: "pipe",
});
child.stdin.write("dylan\n");
Bun.sleepSync(100);
child.stdin.write("999\n");
Bun.sleepSync(100);
child.stdin.write("hi\n");
expect(await child.exited).toBe(0);
var out = "";
for await (const chunk of child.stdout) {
out += new TextDecoder().decode(chunk);
}
expect(out).toContain('twitter: "@dylan"');
expect(out).toContain("age: 999");
expect(out).toContain('secret: "hi"');
});
|