import { describe, expect, it } from "vitest"; import { humanizeIdentifier, planCodeLabel, providerLabel, supportPriorityLabelKey, supportSourceLabel, supportStatusLabelKey, } from "./adminEnumLabels"; describe("supportStatusLabelKey", () => { it("resolves the same keys the ticket detail already used", () => { // The inbox printed `open` while the detail printed "Offen". expect(supportStatusLabelKey("open")).toBe("admin.support.status.open"); expect(supportStatusLabelKey("closed")).toBe("admin.support.status.closed"); }); it("returns null for unknown values instead of inventing a key", () => { expect(supportStatusLabelKey("escalated")).toBeNull(); expect(supportStatusLabelKey("")).toBeNull(); }); }); describe("supportPriorityLabelKey", () => { it("resolves known priorities", () => { expect(supportPriorityLabelKey("normal")).toBe("admin.support.priority.normal"); expect(supportPriorityLabelKey("urgent")).toBe("admin.support.priority.urgent"); }); it("returns null for unknown priorities", () => { expect(supportPriorityLabelKey("blocker")).toBeNull(); }); }); describe("humanizeIdentifier", () => { it("makes stored identifiers readable", () => { expect(humanizeIdentifier("business")).toBe("Business"); expect(humanizeIdentifier("past_due")).toBe("Past due"); expect(humanizeIdentifier("admin-sales")).toBe("Admin sales"); expect(humanizeIdentifier("BUSINESS")).toBe("Business"); }); it("keeps an unusable value rather than returning something empty", () => { expect(humanizeIdentifier("")).toBe(""); expect(humanizeIdentifier(" ")).toBe(" "); }); }); describe("supportSourceLabel", () => { it("no longer shows the raw intake channel", () => { expect(supportSourceLabel("seed")).toBe("Seed"); expect(supportSourceLabel("email")).toBe("Email"); expect(supportSourceLabel("inline")).toBe("Inline"); }); }); describe("planCodeLabel", () => { it("matches how /accounts already renders the plan", () => { expect(planCodeLabel("business")).toBe("Business"); expect(planCodeLabel("starter")).toBe("Starter"); expect(planCodeLabel("pro")).toBe("Pro"); }); it("returns null for an unset plan so the caller can render a dash", () => { expect(planCodeLabel(null)).toBeNull(); expect(planCodeLabel(undefined)).toBeNull(); expect(planCodeLabel(" ")).toBeNull(); }); }); describe("providerLabel", () => { it("preserves brand casing", () => { expect(providerLabel("hubspot")).toBe("HubSpot"); expect(providerLabel("mailchimp")).toBe("Mailchimp"); expect(providerLabel("slack")).toBe("Slack"); expect(providerLabel("kwp")).toBe("KWP"); expect(providerLabel("pandadoc")).toBe("PandaDoc"); }); it("humanizes providers that are not in the brand list", () => { expect(providerLabel("custom_webhook")).toBe("Custom webhook"); }); });