Add scheduled invoice delivery

This commit is contained in:
2026-08-17 13:54:45 -04:00
parent 29589c1f32
commit 67ab6b78bd
26 changed files with 2099 additions and 835 deletions
+28
View File
@@ -1,6 +1,12 @@
/// <reference types="bun" />
import { describe, expect, test } from "bun:test";
import {
formatZonedDateTime,
getDefaultScheduledSendAt,
isValidTimeZone,
toLocalDateTimeInputValue,
} from "../src/time-zone";
import {
EXPENSE_CATEGORIES,
formatElapsedSeconds,
@@ -33,3 +39,25 @@ describe("shared domain behavior", () => {
expect(receipt.items[0]?.name).toBe("Coffee");
});
});
describe("time-zone helpers", () => {
test("formats the same instant in the selected IANA time zone", () => {
const instant = new Date("2026-08-17T16:30:00.000Z");
expect(formatZonedDateTime(instant, "America/New_York")).toContain(
"12:30 PM",
);
expect(formatZonedDateTime(instant, "America/Los_Angeles")).toContain(
"9:30 AM",
);
});
test("validates IANA time zones", () => {
expect(isValidTimeZone("America/New_York")).toBe(true);
expect(isValidTimeZone("not/a-zone")).toBe(false);
});
test("rounds the default schedule to the next local hour", () => {
const result = getDefaultScheduledSendAt(new Date(2026, 7, 17, 10, 42, 19));
expect(toLocalDateTimeInputValue(result)).toBe("2026-08-17T11:00");
});
});