import { describe, expect, it } from "vitest"; import { buildCcForecastFormValue } from "@/components/CcForecastFormOrder"; describe("buildCcForecastFormValue", () => { it("maps header + modules to FormOrder fields", () => { const v = buildCcForecastFormValue({ customerName: "新辰泽", header: { F_TransMode: 0, F_OperationType: 0, F_ContainerNo: "WHSU8127240", F_CabinetType: "40HQ", F_ETD: "2026-04-25", F_ETA: "2026-05-15", F_Dock: "洛杉矶", F_BLCopyCode: "WHLC027G597465", F_Classis: 0, F_Instruction: "船名航次 HMM EMERALD 013E", F_MemoRemark: "提拆派组合柜-不带托架", }, modules: { customer_name: "新辰泽", port: "洛杉矶", vessel_voyage: "HMM EMERALD 013E", service: "提拆派组合柜", classis: 0, }, }); expect(v.customerName).toBe("新辰泽"); expect(v.F_ContainerNo).toBe("WHSU8127240"); expect(v.F_CabinetType).toBe("40HQ"); expect(v.F_Dock).toBe("洛杉矶"); expect(v.F_BLCopyCode).toBe("WHLC027G597465"); expect(v.F_ETD).toBe("2026-04-25"); expect(v.F_ETA).toBe("2026-05-15"); expect(v.F_TransMode).toBe(0); expect(v.F_OperationType).toBe(0); expect(v.F_Classis).toBe(0); expect(v.F_Instruction).toContain("HMM EMERALD"); }); it("falls back modules when header empty", () => { const v = buildCcForecastFormValue({ modules: { customer_name: "A", container_no: "ABCD1234567", cabinet_type: "20GP", bl_no: "BL1", port: "LA", vessel_voyage: "V1", }, }); expect(v.F_ContainerNo).toBe("ABCD1234567"); expect(v.F_CabinetType).toBe("20GP"); expect(v.F_BLCopyCode).toBe("BL1"); expect(v.F_Dock).toBe("LA"); expect(v.F_Instruction).toBe("船名航次 V1"); }); });