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.
40 lines
1.2 KiB
40 lines
1.2 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
priority1CustomerDisplayUsd,
|
|
priority1HasMarkup,
|
|
} from "@/lib/priority1/display-price";
|
|
import type { Priority1DisplayLine } from "@/modules/priority1/quote-storage";
|
|
|
|
function line(partial: Partial<Priority1DisplayLine>): Priority1DisplayLine {
|
|
return {
|
|
rank: 1,
|
|
carrier: "Test",
|
|
carrierCode: "TST",
|
|
totalUsd: 100,
|
|
transitDays: 3,
|
|
deliveryDate: null,
|
|
expirationDate: null,
|
|
serviceLevel: "Standard",
|
|
quoteId: null,
|
|
caboUrl: null,
|
|
source: "visible-dom",
|
|
markup_amount: 0,
|
|
final_total_usd: 100,
|
|
...partial,
|
|
};
|
|
}
|
|
|
|
describe("priority1 display price", () => {
|
|
it("shows final_total_usd when markup applied", () => {
|
|
const row = line({ totalUsd: 428.5, markup_amount: 42.85, final_total_usd: 471.35 });
|
|
expect(priority1CustomerDisplayUsd(row)).toBe(471.35);
|
|
expect(priority1HasMarkup(row)).toBe(true);
|
|
});
|
|
|
|
it("falls back to totalUsd when final is zero", () => {
|
|
const row = line({ totalUsd: 200, markup_amount: 0, final_total_usd: 0 });
|
|
expect(priority1CustomerDisplayUsd(row)).toBe(200);
|
|
expect(priority1HasMarkup(row)).toBe(false);
|
|
});
|
|
});
|