import { describe, expect, it } from "vitest"; import { composeDirective, STYLE_PRESETS } from "./directive"; describe("composeDirective", () => { it("returns empty string when nothing selected", () => { expect(composeDirective("", [])).toBe(""); expect(composeDirective(" ", [])).toBe(""); }); it("uses free text only when no presets", () => { expect(composeDirective("多写战斗", [])).toBe("多写战斗"); }); it("combines presets (in canonical order) then free text", () => { const result = composeDirective("多写战斗", ["fast-pace", "less-ai"]); const lessAi = STYLE_PRESETS.find((p) => p.id === "less-ai")!.text; const fastPace = STYLE_PRESETS.find((p) => p.id === "fast-pace")!.text; expect(result).toBe(`${lessAi};${fastPace};多写战斗`); }); it("ignores unknown preset ids", () => { const lessAi = STYLE_PRESETS.find((p) => p.id === "less-ai")!.text; expect(composeDirective("", ["nope", "less-ai"])).toBe(lessAi); }); });