YARA-1267, YARA-1268

This commit is contained in:
SepehrYahyaee
2026-09-08 14:51:51 +03:30
parent 0e861ff6d1
commit 55da8188a9
3 changed files with 60 additions and 24 deletions

View File

@@ -184,6 +184,11 @@ describe("SandHubService inquiry mocks", () => {
it("does not accept a policy when CLIENT_ID is not configured", async () => {
delete process.env.CLIENT_ID;
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
jest.spyOn(service, "getTejaratCarBodyInquiry").mockResolvedValue({
raw: { data: { companyId: "15" } },
mapped: { companyId: "15", CompanyCode: "15" },
});
await expect(service.getCarBodyInquiry(userDetail)).rejects.toBeInstanceOf(
ServiceUnavailableException,
@@ -207,6 +212,7 @@ describe("SandHubService inquiry mocks", () => {
it("rejects a CAR_BODY policy from another insurer on the Tejarat lookup route", async () => {
process.env.CLIENT_ID = "15";
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
jest.spyOn(service, "getTejaratCarBodyInquiry").mockResolvedValue({
raw: { data: { companyId: "8" } },
mapped: { companyId: "8", CompanyCode: "8" },
@@ -217,6 +223,24 @@ describe("SandHubService inquiry mocks", () => {
);
});
it("accepts a mocked Parsian CAR_BODY inquiry for the deployment client", async () => {
process.env.CLIENT_ID = "15";
process.env.FANAVARAN_CLIENT = "parsian";
externalInquirySettings.isInquiryLive.mockResolvedValue(false);
externalInquirySettings.getMockCompanyContext.mockResolvedValue({
companyId: "15",
companyName: "بیمه سامان",
});
await expect(service.getCarBodyInquiry(userDetail)).resolves.toEqual(
expect.objectContaining({
source: "ESG_CAR_BODY_INQUIRY",
mapped: expect.objectContaining({ companyId: 15 }),
}),
);
expect(lookupsService.findLastProcessedCarPolicy).not.toHaveBeenCalled();
});
it("uses the processed CAR_BODY lookup when the active Fanavaran client is Parsian", async () => {
process.env.FANAVARAN_CLIENT = "parsian";
externalInquirySettings.isInquiryLive.mockResolvedValue(true);