Cron: guard missing expr in schedule parsing

This commit is contained in:
Vignesh Natarajan
2026-02-21 20:18:11 -08:00
parent eea0a68199
commit 961bde27fe
6 changed files with 45 additions and 2 deletions

View File

@@ -13,6 +13,18 @@ describe("cron schedule", () => {
expect(next).toBe(Date.parse("2025-12-17T17:00:00.000Z"));
});
it("throws a clear error when cron expr is missing at runtime", () => {
const nowMs = Date.parse("2025-12-13T00:00:00.000Z");
expect(() =>
computeNextRunAtMs(
{
kind: "cron",
} as unknown as { kind: "cron"; expr: string; tz?: string },
nowMs,
),
).toThrow("invalid cron schedule: expr is required");
});
it("computes next run for every schedule", () => {
const anchor = Date.parse("2025-12-13T00:00:00.000Z");
const now = anchor + 10_000;