20 lines
639 B
TypeScript
20 lines
639 B
TypeScript
import { describe, it, expect } from "vitest"
|
|
import { dayKey } from "../../app/utils/dayKey"
|
|
|
|
describe("dayKey", () => {
|
|
it("returns the YYYY-MM-DD slice of an ISO datetime", () => {
|
|
expect(dayKey("2026-06-13T09:42:00Z")).toBe("2026-06-13")
|
|
})
|
|
|
|
it("handles an ISO datetime with offset and fractional seconds", () => {
|
|
expect(dayKey("2026-12-31T23:59:59.999+02:00")).toBe("2026-12-31")
|
|
})
|
|
|
|
it("returns a bare date string unchanged", () => {
|
|
expect(dayKey("2026-01-05")).toBe("2026-01-05")
|
|
})
|
|
|
|
it("returns the whole string when shorter than 10 chars", () => {
|
|
expect(dayKey("2026-06")).toBe("2026-06")
|
|
})
|
|
})
|