37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
|
|
import { IProfileContext } from "../Profile.context";
|
||
|
|
import { createProfileMapper } from "./profile.mapper";
|
||
|
|
|
||
|
|
const source = (defaultShowLineDiscountColumn: boolean | null) =>
|
||
|
|
({
|
||
|
|
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,
|
||
|
|
},
|
||
|
|
}) 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);
|
||
|
|
});
|
||
|
|
});
|