forked from Yara724/api
fix(claim-pricing): keep invoice and repair states consistent
This commit is contained in:
@@ -3,6 +3,41 @@ import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-d
|
||||
import { submitExpertReplyValidationPipe } from "./submit-expert-reply-validation.pipe";
|
||||
|
||||
describe("submitExpertReplyValidationPipe", () => {
|
||||
const replacementInvoice = {
|
||||
partId: 201,
|
||||
typeOfDamage: TypeOfDamage.Change,
|
||||
salary: "1000000",
|
||||
totalPayment: "1000000",
|
||||
factorNeeded: true,
|
||||
daghi: { option: "فاقد ارزش" },
|
||||
};
|
||||
|
||||
it("accepts replacement invoices without a numeric part quote", async () => {
|
||||
const result = await submitExpertReplyValidationPipe.transform(
|
||||
{ parts: [replacementInvoice] },
|
||||
{ type: "body", metatype: SubmitExpertReplyV2Dto },
|
||||
);
|
||||
expect(result.parts[0].factorNeeded).toBe(true);
|
||||
expect(result.parts[0].price).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each([{ factorNeeded: false }, { price: "factor" }, { price: "فاکتور" }])(
|
||||
"continues rejecting absent priced quotes and nonnumeric price markers: %j",
|
||||
async (invalid) => {
|
||||
await expect(
|
||||
submitExpertReplyValidationPipe.transform(
|
||||
{ parts: [{ ...replacementInvoice, ...invalid }] },
|
||||
{ type: "body", metatype: SubmitExpertReplyV2Dto },
|
||||
),
|
||||
).rejects.toMatchObject({
|
||||
response: {
|
||||
validationErrors: expect.arrayContaining([
|
||||
expect.objectContaining({ field: "parts[0].price" }),
|
||||
]),
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
it("converts DTO validation failures into Persian, field-addressable errors", async () => {
|
||||
await expect(
|
||||
submitExpertReplyValidationPipe.transform(
|
||||
@@ -61,7 +96,7 @@ describe("submitExpertReplyValidationPipe", () => {
|
||||
validationErrors: expect.arrayContaining([
|
||||
{
|
||||
field: "parts[0].salary",
|
||||
message: "باید مبلغ صحیح و غیرمنفی به تومان باشد.",
|
||||
message: "باید مبلغ صحیح و غیرمنفی به ریال باشد.",
|
||||
},
|
||||
]),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user