28 lines
942 B
TypeScript
28 lines
942 B
TypeScript
import { describe, it, expect } from "vitest"
|
|
import { utcDay } from "../../app/utils/utcDay"
|
|
|
|
describe("utcDay", () => {
|
|
it("returns noon UTC for the day of an ISO string, ignoring late-night time", () => {
|
|
const d = utcDay("2026-06-13T23:30:00Z")
|
|
expect(d.getUTCFullYear()).toBe(2026)
|
|
expect(d.getUTCMonth()).toBe(5)
|
|
expect(d.getUTCDate()).toBe(13)
|
|
expect(d.getUTCHours()).toBe(12)
|
|
})
|
|
|
|
it("pins to noon UTC regardless of the time portion (early morning)", () => {
|
|
const d = utcDay("2026-01-01T00:05:00Z")
|
|
expect(d.getUTCFullYear()).toBe(2026)
|
|
expect(d.getUTCMonth()).toBe(0)
|
|
expect(d.getUTCDate()).toBe(1)
|
|
expect(d.getUTCHours()).toBe(12)
|
|
})
|
|
|
|
it("works for a bare date-only ISO string", () => {
|
|
const d = utcDay("2024-12-31")
|
|
expect(d.getUTCFullYear()).toBe(2024)
|
|
expect(d.getUTCMonth()).toBe(11)
|
|
expect(d.getUTCDate()).toBe(31)
|
|
expect(d.getUTCHours()).toBe(12)
|
|
})
|
|
})
|