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.
65 lines
2.0 KiB
65 lines
2.0 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
revalidateShipmentRow,
|
|
sanitizeClientShipments,
|
|
} from "@/services/parse/revalidate-shipment-row";
|
|
|
|
describe("revalidateShipmentRow", () => {
|
|
it("marks incomplete row INVALID", () => {
|
|
const row = revalidateShipmentRow({ row_index: 0 });
|
|
expect(row.row_status).toBe("INVALID");
|
|
expect(row.invalid_reasons?.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("accepts truck row with qty/cbm/weight", () => {
|
|
const row = revalidateShipmentRow({
|
|
row_index: 0,
|
|
channel_raw: "TRUCK",
|
|
F_FBACode: "ONT8",
|
|
F_CTNS: 10,
|
|
F_CBM: 1.2,
|
|
F_Weight: 100,
|
|
F_ShipmentID: "REF-1",
|
|
});
|
|
expect(row.row_status).toBe("VALID");
|
|
expect(row.F_Transporter).toBe("TRUCK");
|
|
expect(row.F_ShipmentID).toBe("REF-1");
|
|
});
|
|
|
|
it("sanitizeClientShipments reindexes", () => {
|
|
const rows = sanitizeClientShipments([
|
|
{
|
|
row_index: 9,
|
|
channel_raw: "UPS",
|
|
F_CTNS: 1,
|
|
F_CBM: 0.1,
|
|
F_Weight: 2,
|
|
},
|
|
]);
|
|
expect(rows).toHaveLength(1);
|
|
expect(rows[0].row_index).toBe(0);
|
|
expect(rows[0].row_status).toBe("VALID");
|
|
});
|
|
|
|
it("splits labeled Address blob into city/state/contact/mobile", () => {
|
|
const blob =
|
|
"仓库代码: LAS1 收件人: LAS1 公司名称: AMAZON COM SERVICES INC 联系电话: 0123456789 省/市/区: NV / HENDERSON / 邮政编码: 89044-8746 收货地址: 12300 Bermuda Road";
|
|
const row = revalidateShipmentRow({
|
|
row_index: 0,
|
|
channel_raw: "TRUCK",
|
|
F_CTNS: 44,
|
|
F_CBM: 5.14,
|
|
F_Weight: 567,
|
|
F_Address: blob,
|
|
});
|
|
expect(row.F_Address).toBe("12300 Bermuda Road");
|
|
expect(row.F_City).toBe("HENDERSON");
|
|
expect(row.F_State).toBe("NV");
|
|
expect(row.F_ZipCode).toBe("89044-8746");
|
|
expect(row.F_Contact).toBe("LAS1");
|
|
expect(row.F_Mobile).toBe("0123456789");
|
|
expect(row.F_EnglishName).toBe("AMAZON COM SERVICES INC");
|
|
expect(row.F_FBACode).toBe("LAS1");
|
|
});
|
|
});
|