e710d97d74
- Improved config display formatting to properly render arrays and objects as JSON instead of `[object Object]`. - Enhanced type display in config list output to show correct type indicators for number, array, and record settings. - Added test coverage for record settings rendering in config list output.
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "bun:test";
|
|
import { runConfigCommand } from "../src/cli/config-cli";
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
describe("config CLI schema coverage", () => {
|
|
it("lists non-UI schema settings in JSON output", async () => {
|
|
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
|
|
await runConfigCommand({ action: "list", flags: { json: true } });
|
|
|
|
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
const payload = logSpy.mock.calls[0]?.[0];
|
|
expect(typeof payload).toBe("string");
|
|
const parsed = JSON.parse(String(payload)) as Record<string, { type: string; description: string }>;
|
|
|
|
expect(parsed.enabledModels).toBeDefined();
|
|
expect(parsed.enabledModels.type).toBe("array");
|
|
expect(parsed.enabledModels.description).toBe("");
|
|
});
|
|
|
|
it("gets non-UI schema settings by key", async () => {
|
|
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
|
|
await runConfigCommand({ action: "get", key: "enabledModels", flags: { json: true } });
|
|
|
|
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
const payload = logSpy.mock.calls[0]?.[0];
|
|
expect(typeof payload).toBe("string");
|
|
const parsed = JSON.parse(String(payload)) as {
|
|
key: string;
|
|
type: string;
|
|
description: string;
|
|
};
|
|
|
|
expect(parsed.key).toBe("enabledModels");
|
|
expect(parsed.type).toBe("array");
|
|
expect(parsed.description).toBe("");
|
|
});
|
|
|
|
it("renders record settings as JSON and with record type in text output", async () => {
|
|
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
|
|
await runConfigCommand({ action: "list", flags: {} });
|
|
|
|
const lines = logSpy.mock.calls.map(call => String(call[0] ?? ""));
|
|
const modelRolesLine = lines.find(line => line.includes("modelRoles ="));
|
|
expect(modelRolesLine).toBeDefined();
|
|
expect(modelRolesLine).toContain("modelRoles = {}");
|
|
expect(modelRolesLine).toContain("(record)");
|
|
expect(modelRolesLine).not.toContain("[object Object]");
|
|
});
|
|
});
|