import { describe, expect, test } from "bun:test";
import { icon } from "@xynogen/pix-pretty/icon-catalog";
import { compactStatus, renderThinkingLevel } from "./footer.ts";
const theme = {
fg: (_color: string, text: string) => text,
getThinkingBorderColor: (level: string) => (text: string) => `<${level}>${text}${level}>`,
};
describe("renderThinkingLevel", () => {
test("uses the host theme's canonical thinking-level renderer", () => {
expect(renderThinkingLevel(theme, "high", "high")).toBe("high");
expect(renderThinkingLevel(theme, "xhigh", "xhigh")).toBe("xhigh");
});
test("renders unknown levels with the neutral muted color", () => {
const calls: string[] = [];
const recordingTheme = {
fg: (color: string, text: string) => {
calls.push(color);
return text;
},
getThinkingBorderColor: theme.getThinkingBorderColor,
};
expect(renderThinkingLevel(recordingTheme, "future", "future")).toBe("future");
expect(calls).toEqual(["muted"]);
});
});
describe("compactStatus", () => {
test("compacts current pi-lens active server lists to a count", () => {
expect(compactStatus("pi-lens-lsp", "LSP Active: json, yaml, typescript", theme)).toBe(
`${icon("lsp")} 3`,
);
});
test("preserves active and failed counts without listing server names", () => {
expect(compactStatus("pi-lens-lsp", "LSP Active: json, yaml ยท LSP Failed: eslint", theme)).toBe(
`${icon("lsp")} 2 !1`,
);
});
test("keeps compatibility with the older parenthesized count", () => {
expect(compactStatus("pi-lens-lsp", "LSP Active (4)", theme)).toBe(`${icon("lsp")} 4`);
});
});