import { describe, expect, it } from "vitest"; import { deriveHiveFacts } from "./facts"; import { hiveFactsText, shortGermanDay, sourceLabel } from "./summary"; import { frames, inlineCatalog, part } from "./test-utils"; import type { HiveState } from "./types"; const catalog = inlineCatalog(); describe("shortGermanDay", () => { it("writes 2026-10-12 as 12.10.", () => { expect(shortGermanDay("2026-10-12")).toBe("12.10."); }); }); describe("sourceLabel", () => { it("names the sources the way the beekeeper knows them", () => { expect(sourceLabel("CARD")).toBe("Karte"); expect(sourceLabel("EDITOR")).toBe("Umbau"); expect(sourceLabel("INSPECTION")).toBe("Durchsicht"); expect(sourceLabel("INIT")).toBe("Angelegt"); }); }); describe("hiveFactsText", () => { it("lists boxes, brood, feed and the floor insert", () => { const state: HiveState = { schemaVersion: 1, stack: [ part("f", "floor", { inserts: [part("fi", "floor-insert")] }), part("b1", "box", { frames: frames(3, "BROOD") }), part("b2", "box", { frames: frames(3, "BROOD") }), part("fe", "feeder", { state: { syrupLiters: 3, fondantKg: 0 } }), part("fe2", "feeder", { state: { syrupLiters: 2, fondantKg: 0 } }), ], }; expect(hiveFactsText(deriveHiveFacts(state, catalog))).toBe( "2 Zargen · 6 Brutwaben · Futter 5 l · Bausperre drin", ); }); it("uses singular forms and leaves out what is not there", () => { const state: HiveState = { schemaVersion: 1, stack: [part("b1", "box", { frames: frames(1, "BROOD") })], }; expect(hiveFactsText(deriveHiveFacts(state, catalog))).toBe("1 Zarge · 1 Brutwabe"); }); it("shows acid of an evaporator", () => { const state: HiveState = { schemaVersion: 1, stack: [part("b1", "box", { frames: frames(1), inserts: [part("ev", "evaporator", { state: { acidMl: 40 } })] })], }; expect(hiveFactsText(deriveHiveFacts(state, catalog))).toContain("Säure 40 ml"); }); });