25 lines
842 B
TypeScript
25 lines
842 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { getDashboardDateWindows } from "@/lib/admin-dashboard";
|
|
|
|
describe("admin dashboard date windows", () => {
|
|
test("uses Bangkok-local midnight for today", () => {
|
|
const windows = getDashboardDateWindows(
|
|
new Date("2026-07-27T18:30:00.000Z")
|
|
);
|
|
|
|
expect(windows.todayStart.toISOString()).toBe("2026-07-27T17:00:00.000Z");
|
|
expect(windows.tomorrowStart.toISOString()).toBe("2026-07-28T17:00:00.000Z");
|
|
});
|
|
|
|
test("includes today and the previous six Bangkok calendar days", () => {
|
|
const windows = getDashboardDateWindows(
|
|
new Date("2026-07-28T05:00:00.000Z")
|
|
);
|
|
|
|
expect(windows.todayStart.toISOString()).toBe("2026-07-27T17:00:00.000Z");
|
|
expect(windows.last7DaysStart.toISOString()).toBe(
|
|
"2026-07-21T17:00:00.000Z"
|
|
);
|
|
});
|
|
});
|