Make scheduling and dates timezone-safe

This commit is contained in:
2026-08-17 18:15:39 -04:00
parent 1853eaa963
commit 70c08054fb
63 changed files with 2515 additions and 779 deletions
+4 -4
View File
@@ -5,14 +5,14 @@ import { nextDueDate } from "../../web/src/server/services/recurring-invoices";
describe("recurring invoice scheduling", () => {
test("advances weekly schedules from their scheduled occurrence", () => {
const scheduledFor = new Date("2026-08-17T12:00:00.000Z");
expect(nextDueDate("weekly", scheduledFor).toISOString()).toBe(
"2026-08-24T12:00:00.000Z",
);
expect(
nextDueDate("weekly", scheduledFor, "America/New_York").toISOString(),
).toBe("2026-08-24T12:00:00.000Z");
});
test("does not mutate the source date", () => {
const scheduledFor = new Date("2026-08-17T12:00:00.000Z");
nextDueDate("monthly", scheduledFor);
nextDueDate("monthly", scheduledFor, "America/New_York");
expect(scheduledFor.toISOString()).toBe("2026-08-17T12:00:00.000Z");
});
});