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.
34 lines
1.2 KiB
34 lines
1.2 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildWeightDisplayForUnit,
|
|
inferWeightUnitFromFieldHint,
|
|
} from "@/workers/rpa/cargo-weight";
|
|
import { classifyCargoFieldHint } from "@/workers/rpa/fill-cargo-in-drawer";
|
|
|
|
describe("classifyCargoFieldHint", () => {
|
|
it("识别托数/重量/尺寸", () => {
|
|
expect(classifyCargoFieldHint("How many pallets?")).toBe("pallet");
|
|
expect(classifyCargoFieldHint("Weight (lbs)")).toBe("weight");
|
|
expect(classifyCargoFieldHint("Weight (kg)")).toBe("weight");
|
|
expect(classifyCargoFieldHint("重量(公斤)")).toBe("weight");
|
|
expect(classifyCargoFieldHint("Length")).toBe("length");
|
|
expect(classifyCargoFieldHint("Width")).toBe("width");
|
|
expect(classifyCargoFieldHint("Height")).toBe("height");
|
|
expect(classifyCargoFieldHint("需要几个托盘?")).toBe("pallet");
|
|
});
|
|
|
|
it("kg placeholder 仅换算 kg 字段", () => {
|
|
const display = buildWeightDisplayForUnit(
|
|
503,
|
|
inferWeightUnitFromFieldHint("Weight (kg)"),
|
|
);
|
|
expect(display.unit).toBe("kg");
|
|
expect(display.displayValue).not.toBe("503");
|
|
const lbs = buildWeightDisplayForUnit(
|
|
503,
|
|
inferWeightUnitFromFieldHint("Weight (lbs)"),
|
|
);
|
|
expect(lbs.displayValue).toBe("503");
|
|
});
|
|
});
|