@@ -0,0 +1,42 @@
1+import { describe, expect, it } from "bun:test";
2+import { shellTool } from "./shell.ts";
3+
4+describe("shellTool", () => {
5+ it("preserves stdin raw mode if it was enabled", async () => {
6+ // Only run this test if stdin is a TTY, otherwise raw mode concepts don't apply.
7+ if (!process.stdin.isTTY) {
8+ console.log("Skipping raw mode test because stdin is not a TTY");
9+ return;
10+ }
11+
12+ // Set raw mode to true initially
13+ process.stdin.setRawMode(true);
14+ expect(process.stdin.isRaw).toBe(true);
15+
16+ // Execute a quick command
17+ await shellTool.execute({ command: "echo hello" });
18+
19+ // Verify it restored raw mode
20+ expect(process.stdin.isRaw).toBe(true);
21+
22+ // Clean up
23+ process.stdin.setRawMode(false);
24+ });
25+
26+ it("leaves raw mode disabled if it was disabled", async () => {
27+ if (!process.stdin.isTTY) {
28+ console.log("Skipping raw mode test because stdin is not a TTY");
29+ return;
30+ }
31+
32+ // Ensure raw mode is false
33+ process.stdin.setRawMode(false);
34+ expect(process.stdin.isRaw).toBe(false);
35+
36+ // Execute a quick command
37+ await shellTool.execute({ command: "echo hello" });
38+
39+ // Verify it stayed false
40+ expect(process.stdin.isRaw).toBe(false);
41+ });
42+});