forked from Yara724/api
Implemented CAR_BODY fanavaran inquiry
This commit is contained in:
@@ -12,6 +12,9 @@ describe("SandHubService inquiry mocks", () => {
|
||||
const plateNormalizer = {
|
||||
normalizePlateText: (text: string) => text,
|
||||
};
|
||||
const lookupsService = {
|
||||
findLastProcessedCarPolicy: jest.fn(),
|
||||
};
|
||||
|
||||
let service: SandHubService;
|
||||
|
||||
@@ -37,6 +40,7 @@ describe("SandHubService inquiry mocks", () => {
|
||||
{
|
||||
findPlateInquiry: jest.fn().mockResolvedValue(null),
|
||||
} as any,
|
||||
lookupsService as any,
|
||||
);
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(false);
|
||||
externalInquirySettings.getMockCompanyContext.mockResolvedValue({
|
||||
@@ -64,6 +68,77 @@ describe("SandHubService inquiry mocks", () => {
|
||||
expect(result.mapped.platePartThree).toBe(498);
|
||||
});
|
||||
|
||||
it("uses the processed ESG CAR_BODY lookup and preserves it as raw data", async () => {
|
||||
process.env.CLIENT_ID = "8";
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
lookupsService.findLastProcessedCarPolicy.mockResolvedValue({
|
||||
product: "car-body",
|
||||
insuranceLine: "CAR_BODY",
|
||||
insuranceLineId: 4,
|
||||
policyId: 15292336,
|
||||
policy: { CINumber: "70019846985", BeginDate: "1405/05/18" },
|
||||
customer: { Name: "سهيل", LastName: "حاجي زاده" },
|
||||
vehicle: {
|
||||
VIN: "NAAR03HFFRDE07024",
|
||||
plaque: {
|
||||
leftTwoDigits: "16",
|
||||
serialLetter: "ب",
|
||||
threeDigits: "498",
|
||||
rightTwoDigits: "60",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = await service.getCarBodyInquiry(userDetail);
|
||||
|
||||
expect(lookupsService.findLastProcessedCarPolicy).toHaveBeenCalledWith(
|
||||
"car-body",
|
||||
{
|
||||
nationalCode: "1234567890",
|
||||
plaqueLeft: "16",
|
||||
plaqueLetter: "12",
|
||||
plaqueRight: "498",
|
||||
plaqueSerial: "60",
|
||||
},
|
||||
);
|
||||
expect(result.source).toBe("ESG_CAR_BODY_INQUIRY");
|
||||
expect(result.raw.policyId).toBe(15292336);
|
||||
expect(result.mapped.policyNumber).toBe("70019846985");
|
||||
expect(httpService.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps ESG car-body inquiry in mock mode when the per-client toggle is off", async () => {
|
||||
process.env.CLIENT_ID = "8";
|
||||
|
||||
const result = await service.getCarBodyInquiry(userDetail);
|
||||
|
||||
expect(lookupsService.findLastProcessedCarPolicy).not.toHaveBeenCalled();
|
||||
expect(result.source).toBe("ESG_CAR_BODY_INQUIRY");
|
||||
expect(result.raw?.isSuccess).toBe(true);
|
||||
expect(httpService.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses the VIN lookup and VIN audit source for ESG car-body VIN inquiries", async () => {
|
||||
process.env.CLIENT_ID = "8";
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
lookupsService.findLastProcessedCarPolicy.mockResolvedValue({
|
||||
policy: { CINumber: "70019846985" },
|
||||
customer: {},
|
||||
vehicle: {},
|
||||
});
|
||||
|
||||
const result = await service.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: "1234567890",
|
||||
plate: "NAAR03HFFRDE07024",
|
||||
});
|
||||
|
||||
expect(lookupsService.findLastProcessedCarPolicy).toHaveBeenCalledWith(
|
||||
"car-body",
|
||||
{ nationalCode: "1234567890", vin: "NAAR03HFFRDE07024" },
|
||||
);
|
||||
expect(result.source).toBe("ESG_CAR_BODY_VIN_INQUIRY");
|
||||
});
|
||||
|
||||
it("uses car-body mock shape in Tejarat helper when inquiry is off", async () => {
|
||||
const raw = await (service as any).makeTejaratRequest(
|
||||
"http://example/block-inquiry-tejarat/badane",
|
||||
|
||||
Reference in New Issue
Block a user