import { describe, expect, it } from "vitest"; import { buildAddressCandidatesCacheHash } from "@/modules/address/candidates-cache"; describe("buildAddressCandidatesCacheHash", () => { const pickup = { street: "5678 Distribution Dr", city: "Dallas", state: "TX", zip: "75201", }; const delivery = { street: "1234 Warehouse Blvd", city: "Los Angeles", state: "CA", zip: "90001", }; it("相同地址生成相同 hash", () => { const a = buildAddressCandidatesCacheHash({ pickup, delivery }); const b = buildAddressCandidatesCacheHash({ pickup, delivery }); expect(a).toBe(b); expect(a).toMatch(/^[a-f0-9]{32}$/); }); it("地址变化生成不同 hash", () => { const a = buildAddressCandidatesCacheHash({ pickup, delivery }); const b = buildAddressCandidatesCacheHash({ pickup: { ...pickup, street: "999 Other St" }, delivery, }); expect(a).not.toBe(b); }); });