shoc-frontend-new/src/test/domain/work-orders/utils/wizard-date-utils.test.ts

31 lines
910 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
});
});