import { describe, expect, it } from "vitest"; import { computeRawHash, computeShipmentsHash, md5 } from "@/utils/hash"; import { toShanghaiDateString, round4 } from "@/utils/dates"; describe("hash/dates", () => { it("md5 lowercase hex", () => { expect(md5("abc")).toBe("900150983cd24fb0d6963f7d28e17f72"); }); it("shipments hash stable", () => { expect(computeShipmentsHash("MATU2745683", [2, 1])).toBe( computeShipmentsHash("MATU2745683", [1, 2]), ); }); it("raw hash differs", () => { expect( computeRawHash({ subject: "a", from: "b", date: "c", filenames: [] }), ).not.toBe( computeRawHash({ subject: "x", from: "b", date: "c", filenames: [] }), ); }); it("shanghai date boundary", () => { const d = new Date("2026-07-12T16:30:00.000Z"); // UTC+8 next day morning expect(toShanghaiDateString(d)).toBe("2026-07-13"); }); it("round4", () => { expect(round4(0.12345)).toBe(0.1235); }); });