You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
import { describe, expect, it } from "vitest";
|
|
import { buildCcTransferFormValue } from "@/components/CcTransferIndexTruck";
|
|
import type { ShipmentRow } from "@/types/mail";
|
|
|
|
describe("buildCcTransferFormValue", () => {
|
|
it("maps container + shipments to IndexTruck query fields", () => {
|
|
const shipments: ShipmentRow[] = [
|
|
{
|
|
row_index: 1,
|
|
row_status: "VALID",
|
|
F_FBACode: "MDW2",
|
|
F_FBAID: "FBA199R49LD6",
|
|
F_ShipmentID: "YT2604021091",
|
|
F_CTNS: 76,
|
|
F_Remark: "转HIA1",
|
|
},
|
|
];
|
|
|
|
const v = buildCcTransferFormValue({
|
|
customerName: "LINK EVER",
|
|
containerNo: "MATU2745683",
|
|
shipments,
|
|
transferPairs: [{ from: "MDW2", to: "HIA1", rows: 1 }],
|
|
});
|
|
|
|
expect(v.F_ContainerNo).toBe("MATU2745683");
|
|
expect(v.F_ContainerCode).toBe("MATU2745683");
|
|
expect(v.F_CustomerName).toBe("LINK EVER");
|
|
expect(v.F_FBACode).toBe("MDW2");
|
|
expect(v.F_ConvertFBACode).toBe("MDW2");
|
|
expect(v.targetFBACode).toBe("HIA1");
|
|
expect(v.F_FBAID).toBe("FBA199R49LD6");
|
|
expect(v.F_ShipmentID).toBe("YT2604021091");
|
|
});
|
|
|
|
it("joins multiple FBACodes and targets from pairs", () => {
|
|
const shipments: ShipmentRow[] = [
|
|
{
|
|
row_index: 1,
|
|
row_status: "VALID",
|
|
F_FBACode: "MDW2",
|
|
F_Remark: "转HIA1",
|
|
},
|
|
{
|
|
row_index: 2,
|
|
row_status: "VALID",
|
|
F_FBACode: "VGT2",
|
|
F_Remark: "转ONT8",
|
|
},
|
|
];
|
|
|
|
const v = buildCcTransferFormValue({
|
|
containerNo: "ABCD1234567",
|
|
shipments,
|
|
transferPairs: [
|
|
{ from: "MDW2", to: "HIA1", rows: 1 },
|
|
{ from: "VGT2", to: "ONT8", rows: 1 },
|
|
],
|
|
});
|
|
|
|
expect(v.F_FBACode).toBe("MDW2,VGT2");
|
|
expect(v.F_ConvertFBACode).toBe("MDW2,VGT2");
|
|
expect(v.targetFBACode).toBe("HIA1,ONT8");
|
|
});
|
|
|
|
it("falls back modules.container_no when containerNo omitted", () => {
|
|
const v = buildCcTransferFormValue({
|
|
modules: { container_no: "WHSU8127240", customer_name: "新辰泽" },
|
|
});
|
|
expect(v.F_ContainerNo).toBe("WHSU8127240");
|
|
expect(v.F_CustomerName).toBe("新辰泽");
|
|
});
|
|
});
|