import { describe, it, expect, vi, beforeEach } from "vitest"; vi.mock("node:fs", () => ({ existsSync: vi.fn(() => false), })); vi.mock("node:os", () => ({ homedir: () => "/home/test", platform: () => "linux", })); import { listPlatformsCommand } from "./list-platforms.js"; beforeEach(() => { vi.clearAllMocks(); }); describe("list-platforms", () => { it("prints all 15 supported platforms", async () => { const log = vi.spyOn(console, "log").mockImplementation(() => {}); await listPlatformsCommand.parseAsync(["node", "list-platforms"], { from: "node", }); const output = log.mock.calls.map((c) => c.join(" ")).join("\n"); log.mockRestore(); // Each registry id must appear in the output for (const id of [ "claude-code", "cursor", "codex", "gemini", "copilot", "windsurf", "cline", "roo", "aide", "augment", "zed", "continue", "opencode", "kiro", "junie", ]) { expect(output).toContain(id); } }); it("emits stable JSON output with --json", async () => { const log = vi.spyOn(console, "log").mockImplementation(() => {}); await listPlatformsCommand.parseAsync( ["node", "list-platforms", "--json"], { from: "node" }, ); const output = log.mock.calls.map((c) => c.join(" ")).join(""); log.mockRestore(); const rows = JSON.parse(output); expect(Array.isArray(rows)).toBe(true); expect(rows.length).toBe(15); for (const row of rows) { expect(row).toHaveProperty("id"); expect(row).toHaveProperty("label"); expect(row).toHaveProperty("detected"); expect(row).toHaveProperty("format"); expect(row).toHaveProperty("path"); expect(row.detected).toBe(false); // existsSync mocked false } // Snapshot the ids in order to lock registry ordering. expect(rows.map((r: { id: string }) => r.id)).toMatchInlineSnapshot(` [ "claude-code", "cursor", "codex", "gemini", "copilot", "windsurf", "cline", "roo", "aide", "augment", "zed", "continue", "opencode", "kiro", "junie", ] `); }); });