import { describe, it, expect } from "bun:test"; import { handleConfigCommand } from "./config.js"; import type { CliRuntime } from "../types.js"; describe("cli/commands/config > aliases and path mapping", () => { const dummyRuntime: CliRuntime = { corpContext: { listCorps: () => [], getCurrent: () => null, switchCorp: () => false, resolve: () => null, } as any, selectedCorp: null, jsonMode: false, }; it("maps config show to config paths diagnosis", async () => { const res = await handleConfigCommand( { area: "config", action: "show", args: [], options: {}, raw: ["config", "show"], }, dummyRuntime ); expect(res.exitCode).toBe(0); expect(res.stdout).toContain("配置路径诊断 (Config Paths)"); expect(res.stdout).toContain("当前生效配置文件"); expect(res.stdout).toContain("运行模式 (Mode)"); }); it("supports config paths directly", async () => { const res = await handleConfigCommand( { area: "config", action: "paths", args: [], options: {}, raw: ["config", "paths"], }, dummyRuntime ); expect(res.exitCode).toBe(0); expect(res.stdout).toContain("配置路径诊断 (Config Paths)"); }); it("supports config show --json structured output", async () => { const jsonRuntime = { ...dummyRuntime, jsonMode: true }; const res = await handleConfigCommand( { area: "config", action: "show", args: [], options: { json: true }, raw: ["config", "show", "--json"], }, jsonRuntime ); expect(res.exitCode).toBe(0); const data = JSON.parse(res.stdout); expect(data).toHaveProperty("configFile"); expect(data).toHaveProperty("writableDir"); expect(data).toHaveProperty("mode"); }); it("supports config get for inspecting global stateful configuration", async () => { const res = await handleConfigCommand( { area: "config", action: "get", args: [], options: {}, raw: ["config", "get"], }, dummyRuntime ); expect(res.exitCode).toBe(0); expect(res.stdout).toContain("全局运行配置"); expect(res.stdout).toContain("运行模式 (Mode)"); }); });