import { describe, expect, it } from "vitest"; import { DOMAIN_EVENT_LABELS, JOB_LABELS, JOB_RUN_STATUS_LABELS, QUEUE_STALE_WARNING_SECONDS, WEBHOOK_DELIVERY_STATUS_LABELS, attemptsLabel, formatAge, } from "./labels"; import { JOB_NAMES } from "./types"; describe("system labels", () => { it("labels every job", () => { expect(JOB_NAMES.every((job) => JOB_LABELS[job].length > 0)).toBe(true); expect(JOB_LABELS.cleanup).toBe("Aufräumen"); }); it("labels the run and delivery states", () => { expect(JOB_RUN_STATUS_LABELS.FAILED).toBe("Fehlgeschlagen"); expect(WEBHOOK_DELIVERY_STATUS_LABELS.DELIVERED).toBe("Zugestellt"); expect(WEBHOOK_DELIVERY_STATUS_LABELS.PENDING).toBe("Offen"); expect(DOMAIN_EVENT_LABELS.InspectionRecorded).toBe("Durchsicht erfasst"); }); it("warns after ten minutes", () => { expect(QUEUE_STALE_WARNING_SECONDS).toBe(600); }); it("pluralises attempts", () => { expect(attemptsLabel(1)).toBe("1 Versuch"); expect(attemptsLabel(0)).toBe("0 Versuche"); expect(attemptsLabel(8)).toBe("8 Versuche"); }); it("formats ages in German", () => { expect(formatAge(5)).toBe("vor wenigen Sekunden"); expect(formatAge(180)).toBe("vor 3 Min."); expect(formatAge(7300)).toBe("vor 2 Std."); expect(formatAge(2 * 86400 + 10)).toBe("vor 2 Tagen"); expect(formatAge(86400)).toBe("vor 1 Tag"); }); });