41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
|
|
import { ISalesContext } from "../Sales.context";
|
||
|
|
import { createQuoteMapper } from "./quote.mapper";
|
||
|
|
|
||
|
|
const source = (showLineDiscountColumn: boolean | null) =>
|
||
|
|
({
|
||
|
|
show_line_discount_column: showLineDiscountColumn,
|
||
|
|
items: [],
|
||
|
|
dataValues: {
|
||
|
|
id: "770672b9-5a87-4e8e-a8af-8b44a7432e12",
|
||
|
|
status: "draft",
|
||
|
|
date: "2026-10-03",
|
||
|
|
reference: "Q-1",
|
||
|
|
currency_code: "EUR",
|
||
|
|
lang_code: "es",
|
||
|
|
customer_reference: "",
|
||
|
|
customer_information: "Customer",
|
||
|
|
validity: "",
|
||
|
|
payment_method: "",
|
||
|
|
notes: "",
|
||
|
|
discount: 0,
|
||
|
|
tax: 21,
|
||
|
|
dealer_id: "770672b9-5a87-4e8e-a8af-8b44a7432e12",
|
||
|
|
date_sent: null,
|
||
|
|
},
|
||
|
|
}) as any;
|
||
|
|
|
||
|
|
describe("QuoteMapper show_line_discount_column", () => {
|
||
|
|
const mapper = createQuoteMapper({} as ISalesContext);
|
||
|
|
|
||
|
|
it("maps false in both persistence directions", () => {
|
||
|
|
const quote = mapper.mapToDomain(source(false));
|
||
|
|
|
||
|
|
expect(quote.showLineDiscountColumn).toBe(false);
|
||
|
|
expect(mapper.mapToPersistence(quote).show_line_discount_column).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("uses true for historical null values", () => {
|
||
|
|
expect(mapper.mapToDomain(source(null)).showLineDiscountColumn).toBe(true);
|
||
|
|
});
|
||
|
|
});
|