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.
71 lines
2.1 KiB
71 lines
2.1 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
evaluateFlockOptionCompat,
|
|
flockOptionHasBlock,
|
|
isFlockReeferOnlyWithoutTemp,
|
|
isFlockSprinterOnly,
|
|
isFlockTempWithoutReefer,
|
|
} from "@/lib/flock/option-compat";
|
|
|
|
describe("Flock 车型×温控", () => {
|
|
it("仅冷藏无温控 → block", () => {
|
|
expect(
|
|
isFlockReeferOnlyWithoutTemp({
|
|
vehicleTypes: ["refrigerated"],
|
|
additionalServices: [],
|
|
}),
|
|
).toBe(true);
|
|
const issues = evaluateFlockOptionCompat({
|
|
pickupLocationType: "business_with_dock",
|
|
deliveryLocationType: "business_with_dock",
|
|
packagingTypes: ["pallets_48x40"],
|
|
vehicleTypes: ["refrigerated"],
|
|
additionalServices: [],
|
|
});
|
|
expect(flockOptionHasBlock(issues)).toBe(true);
|
|
});
|
|
|
|
it("温控无冷藏车 → block", () => {
|
|
expect(
|
|
isFlockTempWithoutReefer({
|
|
vehicleTypes: ["box_truck"],
|
|
additionalServices: ["temperature_control"],
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("冷藏+温控 → 通过", () => {
|
|
expect(
|
|
isFlockReeferOnlyWithoutTemp({
|
|
vehicleTypes: ["refrigerated"],
|
|
additionalServices: ["temperature_control"],
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("仅 sprinter → warn", () => {
|
|
expect(isFlockSprinterOnly(["sprinter"])).toBe(true);
|
|
const issues = evaluateFlockOptionCompat({
|
|
pickupLocationType: "business_with_dock",
|
|
deliveryLocationType: "business_with_dock",
|
|
packagingTypes: ["boxes"],
|
|
vehicleTypes: ["sprinter"],
|
|
additionalServices: [],
|
|
});
|
|
expect(issues.some((i) => i.code === "flock_sprinter_only")).toBe(true);
|
|
});
|
|
|
|
it("施工工地 / units 包装 → warn", () => {
|
|
const issues = evaluateFlockOptionCompat({
|
|
pickupLocationType: "business_with_dock",
|
|
deliveryLocationType: "limited_construction",
|
|
packagingTypes: ["units"],
|
|
vehicleTypes: ["box_truck", "dry_van", "refrigerated"],
|
|
additionalServices: [],
|
|
});
|
|
expect(flockOptionHasBlock(issues)).toBe(false);
|
|
expect(issues.some((i) => i.code.includes("construction"))).toBe(true);
|
|
expect(issues.some((i) => i.code.includes("units"))).toBe(true);
|
|
});
|
|
});
|