31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { describe, it, expect } from "vitest"
|
||
import { formatDateRange } from "../../app/utils/formatDateRange"
|
||
|
||
describe("formatDateRange", () => {
|
||
it("returns a single full date when both ISO datetimes fall on the same day", () => {
|
||
const out = formatDateRange("2026-06-13T08:00:00Z", "2026-06-13T22:30:00Z")
|
||
expect(out).toContain("juin 2026")
|
||
expect(out).not.toContain(" – ")
|
||
expect(out).toBe("13 juin 2026")
|
||
})
|
||
|
||
it("collapses the start day when same month different day", () => {
|
||
const out = formatDateRange("2026-06-13T10:00:00Z", "2026-06-14T18:00:00Z")
|
||
expect(out).toBe("13 – 14 juin 2026")
|
||
})
|
||
|
||
it("renders both full dates with months when the range crosses months", () => {
|
||
const out = formatDateRange("2026-06-28T10:00:00Z", "2026-07-02T18:00:00Z")
|
||
expect(out).toContain(" – ")
|
||
expect(out).toContain("juin")
|
||
expect(out).toContain("juillet")
|
||
expect(out).toBe("28 juin 2026 – 2 juillet 2026")
|
||
})
|
||
|
||
it("renders both full dates when the range crosses years", () => {
|
||
const out = formatDateRange("2026-12-30T10:00:00Z", "2027-01-02T18:00:00Z")
|
||
expect(out).toContain(" – ")
|
||
expect(out).toContain("2026")
|
||
expect(out).toContain("2027")
|
||
})
|
||
})
|