2026-10-03 13:14:49 +00:00
|
|
|
import { IProfileContext } from "../Profile.context";
|
|
|
|
|
import { createProfileMapper } from "./profile.mapper";
|
|
|
|
|
|
2026-10-05 08:59:59 +00:00
|
|
|
const source = (defaultShowLineDiscountColumn: boolean | null, defaultTaxLabel?: string | null) =>
|
2026-10-03 13:14:49 +00:00
|
|
|
({
|
|
|
|
|
default_show_line_discount_column: defaultShowLineDiscountColumn,
|
|
|
|
|
dataValues: {
|
|
|
|
|
id: "770672b9-5a87-4e8e-a8af-8b44a7432e12",
|
|
|
|
|
name: "Dealer",
|
|
|
|
|
status: "actived",
|
|
|
|
|
lang_code: "es",
|
|
|
|
|
currency_code: "EUR",
|
|
|
|
|
logo: "",
|
|
|
|
|
contact_information: "",
|
|
|
|
|
default_payment_method: "",
|
|
|
|
|
default_notes: "",
|
|
|
|
|
default_legal_terms: "",
|
|
|
|
|
default_quote_validity: "",
|
|
|
|
|
default_tax: 2100,
|
2026-10-05 08:59:59 +00:00
|
|
|
default_tax_label: defaultTaxLabel,
|
2026-10-03 13:14:49 +00:00
|
|
|
},
|
|
|
|
|
}) as any;
|
|
|
|
|
|
|
|
|
|
describe("ProfileMapper default_show_line_discount_column", () => {
|
|
|
|
|
const mapper = createProfileMapper({} as IProfileContext);
|
|
|
|
|
|
|
|
|
|
it("maps false in both persistence directions", () => {
|
|
|
|
|
const profile = mapper.mapToDomain(source(false));
|
|
|
|
|
|
|
|
|
|
expect(profile.defaultShowLineDiscountColumn).toBe(false);
|
|
|
|
|
expect(mapper.mapToPersistence(profile).default_show_line_discount_column).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("uses true for historical null values", () => {
|
|
|
|
|
expect(mapper.mapToDomain(source(null)).defaultShowLineDiscountColumn).toBe(true);
|
|
|
|
|
});
|
2026-10-05 08:59:59 +00:00
|
|
|
|
|
|
|
|
it("maps a tax label in both persistence directions", () => {
|
|
|
|
|
const profile = mapper.mapToDomain(source(true, "% IGIC"));
|
|
|
|
|
|
|
|
|
|
expect(profile.defaultTaxLabel.toString()).toBe("% IGIC");
|
|
|
|
|
expect(mapper.mapToPersistence(profile).default_tax_label).toBe("% IGIC");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("uses the default tax label for historical null values", () => {
|
|
|
|
|
expect(mapper.mapToDomain(source(true, null)).defaultTaxLabel.toString()).toBe("% IVA");
|
|
|
|
|
});
|
2026-10-03 13:14:49 +00:00
|
|
|
});
|