forked from Yara724/api
Route inquiries by participant role
This commit is contained in:
@@ -9,7 +9,9 @@ import {
|
||||
isMappedPolicyCurrent,
|
||||
normalizeInquirySubmission,
|
||||
participantForRole,
|
||||
participantForStoredPartyRole,
|
||||
resolveInquiryParticipants,
|
||||
resolveInquirySubjects,
|
||||
resolveInquiryVehicle,
|
||||
runPlateInquiryWithFallback,
|
||||
vehiclePlateCandidates,
|
||||
@@ -160,6 +162,62 @@ describe("inquiry participant resolver", () => {
|
||||
expect(normalized.vehicleOwner?.nationalCode).toBe("0012345678");
|
||||
});
|
||||
|
||||
it("routes each inquiry to its domain participant", () => {
|
||||
const normalized = normalizeInquirySubmission(BlameRequestType.CAR_BODY, {
|
||||
vehicle: {
|
||||
currentPlate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
},
|
||||
driver: {
|
||||
nationalCode: "0011111111",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: {
|
||||
nationalCode: "0022222222",
|
||||
birthday: "1365/02/02",
|
||||
},
|
||||
thirdPartyPolicyholder: {
|
||||
nationalCode: "0033333333",
|
||||
birthday: "1360/03/03",
|
||||
},
|
||||
carBodyPolicyholder: {
|
||||
nationalCode: "0044444444",
|
||||
birthday: "1355/04/04",
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolveInquirySubjects(normalized)).toEqual({
|
||||
thirdPartyPolicyNationalCode: "0033333333",
|
||||
carBodyPolicyNationalCode: "0044444444",
|
||||
shebaNationalCode: "0022222222",
|
||||
driverNationalCode: "0011111111",
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves a persisted vehicle owner for later Sheba validation", () => {
|
||||
const party = {
|
||||
participants: [
|
||||
{ participantId: "DRIVER", nationalCode: "0011111111" },
|
||||
{ participantId: "VEHICLE_OWNER", nationalCode: "0022222222" },
|
||||
],
|
||||
participantRoles: {
|
||||
driver: "DRIVER",
|
||||
vehicleOwner: "VEHICLE_OWNER",
|
||||
thirdPartyPolicyholder: "DRIVER",
|
||||
},
|
||||
};
|
||||
|
||||
expect(
|
||||
participantForStoredPartyRole(party, InquiryParticipantRole.VEHICLE_OWNER)
|
||||
?.nationalCode,
|
||||
).toBe("0022222222");
|
||||
});
|
||||
|
||||
it("orders the current plate before the previous-plate fallback", () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
|
||||
Reference in New Issue
Block a user