forked from Yara724/api
fanavaran stages matching data is double checked and more controlled +
This commit is contained in:
133
src/claim-request-management/fanavaran-claim-product.spec.ts
Normal file
133
src/claim-request-management/fanavaran-claim-product.spec.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
||||
import { PartyRole } from "src/request-management/entities/schema/partyRole.enum";
|
||||
import {
|
||||
fanavaranClaimProductFromBlameType,
|
||||
fanavaranClaimsBaseUrl,
|
||||
fanavaranPartyInquirySources,
|
||||
isFanavaranSubmitSupportedBlameType,
|
||||
pickCarBodyPolicyNationalCode,
|
||||
pickStoredCarBodyPolicyId,
|
||||
} from "./fanavaran-claim-product";
|
||||
|
||||
describe("fanavaran claim product", () => {
|
||||
it("maps CAR_BODY blame files onto the hull claims resource", () => {
|
||||
expect(fanavaranClaimProductFromBlameType(BlameRequestType.CAR_BODY)).toBe(
|
||||
"car-body",
|
||||
);
|
||||
expect(fanavaranClaimsBaseUrl("car-body")).toBe(
|
||||
"https://apimanager.iraneit.com/BimeApiManager/api/BimeApi/v2.0/car/vehicle-hull-claims",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps THIRD_PARTY on the financial third-party claims resource", () => {
|
||||
expect(
|
||||
fanavaranClaimProductFromBlameType(BlameRequestType.THIRD_PARTY),
|
||||
).toBe("third-party");
|
||||
expect(fanavaranClaimsBaseUrl("third-party")).toBe(
|
||||
"https://apimanager.iraneit.com/BimeApiManager/api/BimeApi/v2.0/car/third-party-car-financial-claims",
|
||||
);
|
||||
});
|
||||
|
||||
it("allows Fanavaran submit for both car products", () => {
|
||||
expect(isFanavaranSubmitSupportedBlameType("THIRD_PARTY")).toBe(true);
|
||||
expect(isFanavaranSubmitSupportedBlameType("CAR_BODY")).toBe(true);
|
||||
expect(isFanavaranSubmitSupportedBlameType("OTHER")).toBe(false);
|
||||
});
|
||||
|
||||
it("reuses the car-body inquiry PolicyId without another policy list call", () => {
|
||||
const policyId = pickStoredCarBodyPolicyId({
|
||||
parties: [
|
||||
{
|
||||
role: PartyRole.FIRST,
|
||||
insurance: { carBodyInsurance: { policyId: 15292336 } },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(policyId).toBe(15292336);
|
||||
});
|
||||
|
||||
it("reads PolicyId from nested car-body inquiry raw when the flat field is missing", () => {
|
||||
const policyId = pickStoredCarBodyPolicyId({
|
||||
parties: [
|
||||
{
|
||||
role: PartyRole.FIRST,
|
||||
vehicle: {
|
||||
inquiry: {
|
||||
carBody: {
|
||||
mapped: {},
|
||||
raw: { policyId: "15292336", policy: { PolicyId: 99 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(policyId).toBe(15292336);
|
||||
});
|
||||
|
||||
it("uses the first-party car-body policyholder national code", () => {
|
||||
const nationalCode = pickCarBodyPolicyNationalCode({
|
||||
parties: [
|
||||
{
|
||||
role: PartyRole.FIRST,
|
||||
person: { nationalCodeOfInsurer: "0012345678" },
|
||||
insurance: {
|
||||
carBodyInsurance: { ownerNationalCode: "0098765432" },
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(nationalCode).toBe("0012345678");
|
||||
});
|
||||
|
||||
it("flattens car-body inquiry fields onto the damage-case aliases", () => {
|
||||
const { mapped } = fanavaranPartyInquirySources("car-body", {
|
||||
insurance: {
|
||||
carBodyInsurance: {
|
||||
policyNumber: "70019846985",
|
||||
chassisNumber: "IRNKAEK4150012345",
|
||||
},
|
||||
},
|
||||
vehicle: {
|
||||
inquiry: {
|
||||
carBody: {
|
||||
mapped: {
|
||||
policyId: 15292336,
|
||||
policyNumber: "70019846985",
|
||||
chassisNumber: "IRNKAEK4150012345",
|
||||
motorNumber: "M123",
|
||||
vin: "IRNKAEK4150012345",
|
||||
StartDate: "1405/05/18",
|
||||
EndDate: "1406/05/18",
|
||||
builtYear: 1402,
|
||||
platePartOne: "29",
|
||||
plateLetterTitle: "د",
|
||||
platePartThree: "782",
|
||||
plateSerialNumber: "44",
|
||||
},
|
||||
raw: {
|
||||
policy: { CINumber: "70019846985" },
|
||||
vehicle: { ChassisNo: "IRNKAEK4150012345" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(mapped.policyId).toBe(15292336);
|
||||
expect(mapped.PrntCmpDocNo).toBe("70019846985");
|
||||
expect(mapped.ShsNum).toBe("IRNKAEK4150012345");
|
||||
expect(mapped.MtrNum).toBe("M123");
|
||||
expect(mapped.VIN).toBe("IRNKAEK4150012345");
|
||||
expect(mapped.HBgnDte).toBe("1405/05/18");
|
||||
expect(mapped.HEndDte).toBe("1406/05/18");
|
||||
expect(mapped.PrdDte).toBe(1402);
|
||||
expect(mapped.plk1).toBe("29");
|
||||
expect(mapped.plk2).toBe("د");
|
||||
expect(mapped.plk3).toBe("782");
|
||||
expect(mapped.plksrl).toBe("44");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user