mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 08:33:14 +00:00
32 lines
910 B
TypeScript
32 lines
910 B
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
|||
|
|
import {
|
|||
|
|
fmtDateRange,
|
|||
|
|
fmtShortDate,
|
|||
|
|
rangeDayCount,
|
|||
|
|
} from "@/domain/work-orders/utils/wizard-date-utils";
|
|||
|
|
|
|||
|
|
describe("fmtShortDate", () => {
|
|||
|
|
it("formats ISO dates as Mon D", () => {
|
|||
|
|
expect(fmtShortDate("2026-06-08")).toBe("Jun 8");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it("returns em dash for invalid input", () => {
|
|||
|
|
expect(fmtShortDate("")).toBe("—");
|
|||
|
|
expect(fmtShortDate("nope")).toBe("—");
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
describe("fmtDateRange", () => {
|
|||
|
|
it("joins start and end with en dash", () => {
|
|||
|
|
expect(fmtDateRange("2026-06-08", "2026-06-12")).toBe("Jun 8 – Jun 12");
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
describe("rangeDayCount", () => {
|
|||
|
|
it("counts inclusive days order-independently", () => {
|
|||
|
|
expect(rangeDayCount("2026-06-08", "2026-06-12")).toBe(5);
|
|||
|
|
expect(rangeDayCount("2026-06-12", "2026-06-08")).toBe(5);
|
|||
|
|
expect(rangeDayCount("2026-06-08", "2026-06-08")).toBe(1);
|
|||
|
|
});
|
|||
|
|
});
|