forked from Shared/esg
Added car by motor
This commit is contained in:
@@ -49,6 +49,13 @@ export const inquiryEndpointCases: InquiryEndpointCase[] = [
|
||||
validPayload: { postalCode: '1234567890' },
|
||||
invalidPayload: { postalCode: '123' },
|
||||
},
|
||||
{
|
||||
name: 'car by motor inquiry',
|
||||
inquiryType: InquiryType.CAR_BY_MOTOR,
|
||||
path: '/inquiry/carByMotor',
|
||||
validPayload: { nationalCode: '4311402422', motorNo: '147H0403219' },
|
||||
invalidPayload: { nationalCode: 'bad', motorNo: '' },
|
||||
},
|
||||
{
|
||||
name: 'policy by chassis inquiry',
|
||||
inquiryType: InquiryType.POLICY_BY_CHASSIS,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
||||
import { ParsianProvider } from '../../src/providers/implementations/parsian.provider';
|
||||
|
||||
describe('Parsian third-party plate routing', () => {
|
||||
describe('Parsian car inquiry routing', () => {
|
||||
it('uses the one-factor car-by-plate provider path without a national-code lookup', async () => {
|
||||
const inquireCarByPlate = jest.fn().mockResolvedValue({ raw: { policy: true } });
|
||||
const inquireThirdPartyCar = jest.fn();
|
||||
@@ -19,4 +19,25 @@ describe('Parsian third-party plate routing', () => {
|
||||
expect(inquireCarByPlate).toHaveBeenCalledTimes(1);
|
||||
expect(inquireThirdPartyCar).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('routes motor inquiries through the CentInsur motor support path', async () => {
|
||||
const inquireCarByMotor = jest.fn().mockResolvedValue({ raw: { policy: true } });
|
||||
const provider = Object.create(ParsianProvider.prototype) as any;
|
||||
provider.config = {};
|
||||
provider.centInsurCarSupport = { inquireCarByMotor };
|
||||
|
||||
const result = await provider.callProvider(
|
||||
InquiryType.CAR_BY_MOTOR,
|
||||
{ nationalCode: '1234567890', motorNo: '147H0403219' },
|
||||
{ requestId: 'req-2', trackingCode: 'trk-2' },
|
||||
);
|
||||
|
||||
expect(result).toEqual({ raw: { policy: true } });
|
||||
expect(inquireCarByMotor).toHaveBeenCalledWith(
|
||||
{},
|
||||
{ nationalCode: '1234567890', motorNo: '147H0403219' },
|
||||
expect.any(Function),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,8 +2,48 @@ import {
|
||||
getCarPolicyProviderError,
|
||||
parseFirstCarPolicy,
|
||||
} from '../../src/common/helpers/soap-car-policy.helper';
|
||||
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
||||
import { CentInsurCarPolicyClient } from '../../src/providers/shared/centinsur-car-policy.client';
|
||||
|
||||
describe('Parsian car-policy SOAP responses', () => {
|
||||
it('maps motor inquiries to CIIWSPolicyMotor with the MotorNo SOAP field', async () => {
|
||||
const client = new CentInsurCarPolicyClient();
|
||||
const callSoap = jest.spyOn(client as any, 'callSoap').mockResolvedValue({ PlcNo: '123' });
|
||||
const config = { enabled: true, timeout: 1000, maxRetries: 0, inquiries: {} };
|
||||
|
||||
await expect(
|
||||
client.inquireByMotor(config, InquiryType.CAR_BY_MOTOR, '147H0403219'),
|
||||
).resolves.toEqual({ PlcNo: '123' });
|
||||
|
||||
expect(callSoap).toHaveBeenCalledWith(
|
||||
config,
|
||||
InquiryType.CAR_BY_MOTOR,
|
||||
InquiryType.POLICY_BY_PLATE,
|
||||
'CIIWSPolicyMotor',
|
||||
{ MotorNo: '147H0403219' },
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it('parses policy fields from a CIIWSPolicyMotorResult response', () => {
|
||||
const xml = `
|
||||
<CIIWSPolicyMotorResult>
|
||||
<a:Policy>
|
||||
<a:Policy>
|
||||
<a:NtnlId>4311402422</a:NtnlId>
|
||||
<a:MotorNo>147H0403219</a:MotorNo>
|
||||
<a:PlcyNo>987654</a:PlcyNo>
|
||||
</a:Policy>
|
||||
</a:Policy>
|
||||
</CIIWSPolicyMotorResult>`;
|
||||
|
||||
expect(parseFirstCarPolicy(xml)).toEqual({
|
||||
NtnlId: '4311402422',
|
||||
MotorNo: '147H0403219',
|
||||
PlcyNo: '987654',
|
||||
});
|
||||
});
|
||||
|
||||
it('extracts the Persian message from a nested KeyValue error and classifies no-policy', () => {
|
||||
const xml = `
|
||||
<CIIWSPolicyNationalIdResult>
|
||||
|
||||
Reference in New Issue
Block a user