import { getExpertReplyPricingValidationError } from "./expert-reply-pricing"; import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-damage.enum"; import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum"; describe("getExpertReplyPricingValidationError", () => { it("rejects a blank pricing line", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Repair, price: "", salary: "", totalPayment: "", daghi: { option: DaghiOption.NO_VALUE }, }, ]), ).toMatch(/requires valid salary and totalPayment/); }); it("accepts a fully priced line with a zero-valued split", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Repair, price: "0", salary: "10000", totalPayment: "10000", daghi: { option: DaghiOption.NO_VALUE }, }, ]), ).toBeNull(); }); it("accepts a repair line without daghi", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Repair, price: "10000", salary: "0", totalPayment: "10000", }, ]), ).toBeNull(); }); it("rejects a repair line without a price", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Repair, salary: "0", totalPayment: "0", daghi: { option: DaghiOption.NO_VALUE }, }, ]), ).toMatch(/price is also required/); }); it("rejects recycled-value daghi without its price", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Change, salary: "0", totalPayment: "0", daghi: { option: DaghiOption.RECYCLED_PARTS_VALUE }, }, ]), ).toMatch(/requires a valid daghi price/); }); it("accepts a replacement line without a part price", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Change, salary: "0", totalPayment: "0", daghi: { option: DaghiOption.NO_VALUE }, }, ]), ).toBeNull(); }); it("rejects an invalid price when a replacement line supplies one", () => { expect( getExpertReplyPricingValidationError([ { partId: 201, typeOfDamage: TypeOfDamage.Change, price: "not-a-number", salary: "0", totalPayment: "0", daghi: { option: DaghiOption.NO_VALUE }, }, ]), ).toMatch(/requires valid salary and totalPayment/); }); });