Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

test: add formatTextResults tests

riley02274ee75ba45ac5
diff --git a/ix-cli/src/cli/__tests__/format.test.ts b/ix-cli/src/cli/__tests__/format.test.ts
index 62ff5fac..7d8e91a0 100644
--- a/ix-cli/src/cli/__tests__/format.test.ts
+++ b/ix-cli/src/cli/__tests__/format.test.ts
@@ -4,6 +4,7 @@ import {
formatIntents,
formatConflicts,
formatDecisions,
+ formatTextResults,
confidenceColor,
} from "../format.js";
@@ -302,3 +303,31 @@ describe("formatDecisions", () => {
spy.mockRestore();
});
});
+
+describe("formatTextResults", () => {
+ it("should output JSON when format is json", () => {
+ const spy = vi.spyOn(console, "log").mockImplementation(() => {});
+ const results = [{ path: "src/foo.ts", line: 42, snippet: "const foo = bar;" }];
+ formatTextResults(results, "json");
+ expect(spy).toHaveBeenCalledWith(JSON.stringify(results, null, 2));
+ spy.mockRestore();
+ });
+
+ it("should show 'No text matches found.' for empty results", () => {
+ const spy = vi.spyOn(console, "log").mockImplementation(() => {});
+ formatTextResults([], "text");
+ expect(spy).toHaveBeenCalledWith("No text matches found.");
+ spy.mockRestore();
+ });
+
+ it("should display path:line and snippet in text mode", () => {
+ const spy = vi.spyOn(console, "log").mockImplementation(() => {});
+ const results = [{ path: "src/foo.ts", line: 42, snippet: "const foo = bar;" }];
+ formatTextResults(results, "text");
+ const output = spy.mock.calls.map(c => c[0]).join("\n");
+ expect(output).toContain("src/foo.ts");
+ expect(output).toContain(":42");
+ expect(output).toContain("const foo = bar;");
+ spy.mockRestore();
+ });
+});