date.test.ts 688 B

1234567891011121314151617181920
  1. import { describe, expect, test } from "bun:test"
  2. import { getWeekBounds } from "./date"
  3. describe("util.date.getWeekBounds", () => {
  4. test("returns a Monday-based week for Sunday dates", () => {
  5. const date = new Date("2026-01-18T12:00:00Z")
  6. const bounds = getWeekBounds(date)
  7. expect(bounds.start.toISOString()).toBe("2026-01-12T00:00:00.000Z")
  8. expect(bounds.end.toISOString()).toBe("2026-01-19T00:00:00.000Z")
  9. })
  10. test("returns a seven day window", () => {
  11. const date = new Date("2026-01-14T12:00:00Z")
  12. const bounds = getWeekBounds(date)
  13. const span = bounds.end.getTime() - bounds.start.getTime()
  14. expect(span).toBe(7 * 24 * 60 * 60 * 1000)
  15. })
  16. })