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.
85 lines
2.2 KiB
85 lines
2.2 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
containerHeaderFromSheet,
|
|
matchContainerHeaderColumn,
|
|
} from "@/services/parse/container-header-from-sheet";
|
|
|
|
describe("container-header-from-sheet", () => {
|
|
it("matches ClientContainerTemplate header columns exactly", () => {
|
|
expect(matchContainerHeaderColumn("柜号Id")).toBeNull();
|
|
expect(matchContainerHeaderColumn("柜号")).toBe("F_ContainerNo");
|
|
expect(matchContainerHeaderColumn("柜型")).toBe("F_CabinetType");
|
|
expect(matchContainerHeaderColumn("运输方式")).toBe("F_TransModeText");
|
|
expect(matchContainerHeaderColumn("业务类型")).toBe("F_OperationTypeText");
|
|
});
|
|
|
|
it("extracts header from template-like grid", () => {
|
|
const grid = [
|
|
["集装箱信息基础", "", "", "", "", "", "", "", "", "", "", "", "", "", "货件详情"],
|
|
[
|
|
"柜号",
|
|
"柜型",
|
|
"运输方式",
|
|
"业务类型",
|
|
"柜号Id",
|
|
"提单号",
|
|
"ETD",
|
|
"ETA",
|
|
"起始港",
|
|
"目的港",
|
|
"船司",
|
|
"客服",
|
|
"instruction",
|
|
"备注",
|
|
"Move Type",
|
|
"Custmer Ref No",
|
|
"Shipment ID(FBA)",
|
|
"PO",
|
|
"ReferenceId",
|
|
"FBACode",
|
|
"Address",
|
|
"QTY(CTNS)",
|
|
"Vol(CBM)",
|
|
"GW(KGS)",
|
|
],
|
|
[
|
|
"TEST1234567",
|
|
"40HQ",
|
|
"海运",
|
|
"拆柜",
|
|
"TEST1234",
|
|
"TEST1234",
|
|
"2026-06-08",
|
|
"2026-06-20",
|
|
"深圳",
|
|
"纽约",
|
|
"",
|
|
"TEST",
|
|
"",
|
|
"",
|
|
"TRUCK",
|
|
"TEST123456789",
|
|
"FBA123456789",
|
|
"",
|
|
"",
|
|
"TEST",
|
|
"",
|
|
"123",
|
|
"2",
|
|
"2",
|
|
],
|
|
];
|
|
const header = containerHeaderFromSheet(grid, 1, "", {
|
|
enableIsoCheck: false,
|
|
});
|
|
expect(header.F_ContainerNo).toBe("TEST1234567");
|
|
expect(header.F_CabinetType).toBe("40HQ");
|
|
expect(header.F_TransMode).toBe(0);
|
|
expect(header.F_OperationType).toBe(0);
|
|
expect(header.F_ETD).toBe("2026-06-08");
|
|
expect(header.F_ETA).toBe("2026-06-20");
|
|
expect(header.F_LoadPort).toBe("深圳");
|
|
expect(header.F_Dock).toBe("纽约");
|
|
});
|
|
});
|