forked from Yara724/api
94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
import { plainToInstance } from "class-transformer";
|
||
import { validate } from "class-validator";
|
||
import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum";
|
||
import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-damage.enum";
|
||
import { SubmitExpertReplyV2Dto } from "./expert-claim-v2.dto";
|
||
|
||
describe("SubmitExpertReplyV2Dto", () => {
|
||
it("rejects a selected damaged part with blank pricing", async () => {
|
||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||
description: "Damage assessment",
|
||
parts: [
|
||
{
|
||
partId: 201,
|
||
typeOfDamage: TypeOfDamage.Repair,
|
||
price: "",
|
||
salary: "",
|
||
totalPayment: "",
|
||
factorNeeded: false,
|
||
daghi: { option: DaghiOption.NO_VALUE },
|
||
},
|
||
],
|
||
});
|
||
|
||
const errors = await validate(dto);
|
||
|
||
expect(errors).not.toHaveLength(0);
|
||
});
|
||
|
||
it("rejects a replacement part without a price", async () => {
|
||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||
description: "Damage assessment",
|
||
parts: [
|
||
{
|
||
partId: 201,
|
||
typeOfDamage: TypeOfDamage.Change,
|
||
salary: "0",
|
||
totalPayment: "0",
|
||
factorNeeded: false,
|
||
daghi: { option: DaghiOption.NO_VALUE },
|
||
},
|
||
],
|
||
});
|
||
|
||
expect(await validate(dto)).not.toHaveLength(0);
|
||
});
|
||
|
||
it("accepts a repair part without daghi", async () => {
|
||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||
description: "Damage assessment",
|
||
parts: [
|
||
{
|
||
partId: 201,
|
||
typeOfDamage: TypeOfDamage.Repair,
|
||
price: "100000",
|
||
salary: "100000",
|
||
totalPayment: "200000",
|
||
factorNeeded: false,
|
||
},
|
||
],
|
||
});
|
||
|
||
expect(await validate(dto)).toHaveLength(0);
|
||
});
|
||
|
||
it("accepts the expert's repair and replacement pricing rules", async () => {
|
||
const dto = plainToInstance(SubmitExpertReplyV2Dto, {
|
||
description: "Damage assessment",
|
||
parts: [
|
||
{
|
||
partId: 11,
|
||
typeOfDamage: TypeOfDamage.Repair,
|
||
salary: "۱۰۰,۰۰۰",
|
||
totalPayment: "100000",
|
||
factorNeeded: false,
|
||
},
|
||
{
|
||
partId: 23,
|
||
typeOfDamage: TypeOfDamage.Change,
|
||
price: "۱۰۰,۰۰۰",
|
||
salary: "۱۰۰,۰۰۰",
|
||
totalPayment: "150000",
|
||
factorNeeded: false,
|
||
daghi: {
|
||
option: DaghiOption.RECYCLED_PARTS_VALUE,
|
||
price: "۱۰۰,۵۰۰,۰۰۰",
|
||
},
|
||
},
|
||
],
|
||
});
|
||
|
||
expect(await validate(dto)).toHaveLength(0);
|
||
});
|
||
});
|