import { describe, expect, it } from "vitest"; import type { ColonyStatus } from "./types"; import { COLONY_EDITABLE_STATUSES, COLONY_STATUS_LABELS, colonyOptionLabel } from "./labels"; import { ENDED_COLONY_STATUSES, LIVING_COLONY_STATUSES, isLivingColony } from "./status"; const ALL_STATUSES = Object.keys(COLONY_STATUS_LABELS) as ColonyStatus[]; describe("isLivingColony", () => { it.each(["ACTIVE", "WEAK", "CONSPICUOUS", "QUEENLESS"])( "treats a %s colony as still in the apiary", (status) => { expect(isLivingColony({ status })).toBe(true); }, ); it.each(["DISSOLVED", "SOLD", "DECEASED", "MERGED"])( "treats a %s colony as ended", (status) => { expect(isLivingColony({ status })).toBe(false); }, ); it("splits every status into exactly one of living or ended", () => { const partitioned = [...LIVING_COLONY_STATUSES, ...ENDED_COLONY_STATUSES]; expect([...partitioned].sort()).toEqual([...ALL_STATUSES].sort()); expect(new Set(partitioned).size).toBe(partitioned.length); }); it("lets the free status dropdown offer exactly the living statuses", () => { expect(COLONY_EDITABLE_STATUSES).toEqual(LIVING_COLONY_STATUSES); }); }); describe("colonyOptionLabel", () => { it("shows only the code for an ordinary active colony", () => { expect(colonyOptionLabel({ code: "V-01", status: "ACTIVE" })).toBe("V-01"); }); it("names the status of a colony that needs attention", () => { expect(colonyOptionLabel({ code: "V-02", status: "QUEENLESS" })).toBe( "V-02 (Weisellos)", ); expect(colonyOptionLabel({ code: "V-03", status: "WEAK" })).toBe("V-03 (Schwach)"); }); it("names the real end of an ended colony instead of calling all of them dissolved", () => { expect(colonyOptionLabel({ code: "V-04", status: "SOLD" })).toBe("V-04 (Verkauft)"); expect(colonyOptionLabel({ code: "V-05", status: "MERGED" })).toBe( "V-05 (Vereinigt)", ); }); });