forked from Yara724/api
Fixed mock TP Inquiry
This commit is contained in:
@@ -15,6 +15,9 @@ describe("SandHubService inquiry mocks", () => {
|
||||
const lookupsService = {
|
||||
findLastProcessedCarPolicy: jest.fn(),
|
||||
};
|
||||
const offlineInquiryService = {
|
||||
findPlateInquiry: jest.fn(),
|
||||
};
|
||||
|
||||
let service: SandHubService;
|
||||
|
||||
@@ -38,12 +41,11 @@ describe("SandHubService inquiry mocks", () => {
|
||||
sandHubDbService as any,
|
||||
externalInquirySettings as unknown as ExternalInquirySettingsService,
|
||||
plateNormalizer as any,
|
||||
{
|
||||
findPlateInquiry: jest.fn().mockResolvedValue(null),
|
||||
} as any,
|
||||
offlineInquiryService as any,
|
||||
lookupsService as any,
|
||||
);
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(false);
|
||||
offlineInquiryService.findPlateInquiry.mockResolvedValue(null);
|
||||
externalInquirySettings.getMockCompanyContext.mockResolvedValue({
|
||||
companyId: "8",
|
||||
companyName: "بیمه پارسیان",
|
||||
@@ -108,6 +110,28 @@ describe("SandHubService inquiry mocks", () => {
|
||||
expect(httpService.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not let an offline third-party seed override a live ESG inquiry", async () => {
|
||||
process.env.CLIENT_ID = "8";
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
offlineInquiryService.findPlateInquiry.mockResolvedValue({
|
||||
source: "OFFLINE_SEED_INQUIRY",
|
||||
raw: { mocked: true },
|
||||
mapped: { PrntPlcyCmpDocNo: "MOCK-POLICY" },
|
||||
});
|
||||
const esg = jest
|
||||
.spyOn(service as any, "makeEsgRequest")
|
||||
.mockResolvedValue({
|
||||
success: true,
|
||||
data: { PrntCmpDocNo: "REAL-ESG-POLICY" },
|
||||
});
|
||||
|
||||
const result = await service.getTejaratBlockInquiry(userDetail);
|
||||
|
||||
expect(esg).toHaveBeenCalled();
|
||||
expect(result.raw).not.toEqual({ mocked: true });
|
||||
expect(result.mapped.PrntPlcyCmpDocNo).toBe("REAL-ESG-POLICY");
|
||||
});
|
||||
|
||||
it("uses the processed CAR_BODY lookup when the active Fanavaran client is Parsian", async () => {
|
||||
process.env.FANAVARAN_CLIENT = "parsian";
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
|
||||
Reference in New Issue
Block a user