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.
32 lines
791 B
32 lines
791 B
import { describe, expect, it } from "vitest";
|
|
import {
|
|
isHostSelectedQuote,
|
|
mapQuotesWithSelectedFlag,
|
|
} from "@/lib/embed/map-quotes-selection";
|
|
|
|
describe("mapQuotesWithSelectedFlag", () => {
|
|
const a = {
|
|
carrier: "XPO",
|
|
service_level: "standard",
|
|
rate_option: "lowest",
|
|
final_total: 100,
|
|
};
|
|
const b = {
|
|
carrier: "Echo",
|
|
service_level: "standard",
|
|
rate_option: "fastest",
|
|
final_total: 200,
|
|
};
|
|
|
|
it("仅标记与点选项完全匹配的一行 selected=true", () => {
|
|
const mapped = mapQuotesWithSelectedFlag([a, b], b);
|
|
expect(mapped.map((q) => q.selected)).toEqual([false, true]);
|
|
});
|
|
|
|
it("final_total 不同则不算选中", () => {
|
|
expect(
|
|
isHostSelectedQuote(a, { ...a, final_total: 101 }),
|
|
).toBe(false);
|
|
});
|
|
});
|