import { describe, expect, it } from "vitest"; import { nextRunAt } from "./automation.service.js"; describe("automation scheduling", () => { it("computes the next daily run", () => { const next = nextRunAt({ frequency: "daily", time: "03:30", dayOfWeek: 1 }, new Date("2026-08-23T02:00:00.000Z")); expect(next.toISOString()).toBe("2026-08-23T03:30:00.000Z"); }); it("moves elapsed weekly runs to the next week", () => { const next = nextRunAt({ frequency: "weekly", time: "03:30", dayOfWeek: 0 }, new Date("2026-08-23T04:00:00.000Z")); expect(next.toISOString()).toBe("2026-08-30T03:30:00.000Z"); }); });