Skip to content

Commit 32026d2

Browse files
committed
test(agents): add unit tests for exec output rendering helpers
Add unit tests for renderExecOutputText and renderExecUpdateText functions in src/agents/bash-tools.exec-output.ts to verify output rendering behavior. Tests cover: - Placeholder for empty/undefined output - Preserving newlines in output - Warning text placement - Multiple warnings handling - Empty warnings array with tailText - Undefined tailText with warnings
1 parent 17066f2 commit 32026d2

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Tests for exec output rendering helpers.
2+
import { describe, expect, it } from "vitest";
3+
import { renderExecOutputText, renderExecUpdateText } from "./bash-tools.exec-output.js";
4+
5+
describe("renderExecOutputText", () => {
6+
it("returns placeholder for undefined input", () => {
7+
expect(renderExecOutputText(undefined)).toBe("(no output)");
8+
});
9+
10+
it("returns placeholder for empty string", () => {
11+
expect(renderExecOutputText("")).toBe("(no output)");
12+
});
13+
14+
it("returns value for non-empty string", () => {
15+
expect(renderExecOutputText("hello")).toBe("hello");
16+
});
17+
18+
it("returns value for whitespace-only string", () => {
19+
expect(renderExecOutputText(" ")).toBe(" ");
20+
});
21+
22+
it("preserves newlines in output", () => {
23+
expect(renderExecOutputText("line1\nline2")).toBe("line1\nline2");
24+
});
25+
});
26+
27+
describe("renderExecUpdateText", () => {
28+
it("returns placeholder when no tailText and no warnings", () => {
29+
expect(renderExecUpdateText({ warnings: [] })).toBe("(no output)");
30+
});
31+
32+
it("returns tailText when no warnings", () => {
33+
expect(renderExecUpdateText({ tailText: "hello", warnings: [] })).toBe("hello");
34+
});
35+
36+
it("returns warnings when no tailText", () => {
37+
expect(renderExecUpdateText({ warnings: ["warning1"] })).toBe("warning1\n\n(no output)");
38+
});
39+
40+
it("returns warnings followed by tailText", () => {
41+
expect(renderExecUpdateText({ tailText: "hello", warnings: ["warning1"] })).toBe(
42+
"warning1\n\nhello",
43+
);
44+
});
45+
46+
it("joins multiple warnings with newlines", () => {
47+
expect(renderExecUpdateText({ tailText: "hello", warnings: ["warning1", "warning2"] })).toBe(
48+
"warning1\nwarning2\n\nhello",
49+
);
50+
});
51+
52+
it("handles empty warnings array with tailText", () => {
53+
expect(renderExecUpdateText({ tailText: "hello", warnings: [] })).toBe("hello");
54+
});
55+
56+
it("handles undefined tailText with warnings", () => {
57+
expect(renderExecUpdateText({ warnings: ["warning1"] })).toBe("warning1\n\n(no output)");
58+
});
59+
});

0 commit comments

Comments
 (0)