import { describe, expect, it } from "vitest"; import { getVerticalTemplate, listVerticalTemplates } from "../../app/services/templates.server"; describe("getVerticalTemplate", () => { it("lists exactly the three Phase 1 vertical presets", () => { expect(listVerticalTemplates().sort()).toEqual(["bakery", "florist", "grocer"]); }); it.each(listVerticalTemplates())("%s: every slot has a valid weekday and start < end", (vertical) => { const template = getVerticalTemplate(vertical); expect(template.slotTemplates.length).toBeGreaterThan(0); for (const slot of template.slotTemplates) { expect(slot.weekday).toBeGreaterThanOrEqual(0); expect(slot.weekday).toBeLessThanOrEqual(6); expect(slot.startMin).toBeGreaterThanOrEqual(0); expect(slot.endMin).toBeLessThanOrEqual(24 * 60); expect(slot.startMin).toBeLessThan(slot.endMin); expect(slot.capacity).toBeGreaterThan(0); expect(slot.cutoffMin).toBeGreaterThanOrEqual(0); expect(slot.leadTimeMin).toBeGreaterThanOrEqual(0); } }); it("bakery covers Tue-Sat only (closed Sun/Mon)", () => { const weekdays = new Set(getVerticalTemplate("bakery").slotTemplates.map((s) => s.weekday)); expect(weekdays.has(0)).toBe(false); expect(weekdays.has(1)).toBe(false); expect(weekdays.has(2)).toBe(true); expect(weekdays.has(6)).toBe(true); }); it("grocer is the only preset open every day of the week", () => { const weekdays = new Set(getVerticalTemplate("grocer").slotTemplates.map((s) => s.weekday)); expect(weekdays.size).toBe(7); }); it("is deterministic (calling twice yields an equivalent template)", () => { expect(getVerticalTemplate("florist")).toEqual(getVerticalTemplate("florist")); }); });