import { describe, it, expect } from "vitest"; import { kindColor, kindVariant, recordColorKey, KIND_COLOR, KIND_LEGEND } from "../kind-colors"; describe("kindColor", () => { it("returns the canonical hex for a known kind", () => { expect(kindColor("action")).toBe(KIND_COLOR.action); expect(kindColor("workflow")).toBe(KIND_COLOR.workflow); }); it("falls back to the neutral dim for unknown/undefined", () => { expect(kindColor("nope")).toBe("#8a97ad"); expect(kindColor(undefined)).toBe("#8a97ad"); }); }); describe("kindVariant", () => { it("maps dispatch kinds to info", () => { for (const k of ["action", "command", "query", "route"]) { expect(kindVariant(k)).toBe("info"); } }); it("maps app to success and actor/externalCall to warning", () => { expect(kindVariant("app")).toBe("success"); expect(kindVariant("actor")).toBe("warning"); expect(kindVariant("externalCall")).toBe("warning"); }); it("falls back to neutral", () => { expect(kindVariant("event")).toBe("neutral"); expect(kindVariant(undefined)).toBe("neutral"); }); }); describe("recordColorKey", () => { it("maps dotted record kinds back to their handler-kind colour key", () => { expect(recordColorKey("action.completed")).toBe("action"); expect(recordColorKey("event.published")).toBe("event"); expect(recordColorKey("query.executed")).toBe("query"); expect(recordColorKey("projection.folded")).toBe("projection"); expect(recordColorKey("actor.transitioned")).toBe("actor"); }); it("maps family + stage kinds to their group colour", () => { expect(recordColorKey("reaction.fired")).toBe("workflow"); expect(recordColorKey("external.call.failed")).toBe("externalCall"); expect(recordColorKey("source.stage")).toBe("sourceStage"); expect(recordColorKey("sink.stage")).toBe("sinkStage"); expect(kindColor(recordColorKey("external.call.failed"))).toBe(KIND_COLOR.externalCall); }); }); describe("KIND_LEGEND", () => { it("lists the user-facing handler kinds and every entry has a colour", () => { expect(KIND_LEGEND).toContain("action"); expect(KIND_LEGEND).toContain("projection"); for (const k of KIND_LEGEND) expect(kindColor(k)).not.toBe("#8a97ad"); }); });