forked from Yara724/api
Add case identity filters and description validation
This commit is contained in:
@@ -14,15 +14,60 @@ import {
|
||||
resolveInquiryVehicle,
|
||||
runCurrentPlateInquiry,
|
||||
sanitizeStoredInquiryParticipants,
|
||||
validateDriverLicenseDate,
|
||||
} from "./inquiry-participant-resolver";
|
||||
|
||||
describe("inquiry participant resolver", () => {
|
||||
it("accepts a driver licence date within the ten-year window", () => {
|
||||
expect(validateDriverLicenseDate("2016-09-26", "2026-09-26")).toBe(
|
||||
"2016-09-26",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects future and older-than-ten-year driver licence dates", () => {
|
||||
expect(() =>
|
||||
validateDriverLicenseDate("2026-09-27", "2026-09-26"),
|
||||
).toThrow("نمیتواند در آینده");
|
||||
expect(() =>
|
||||
validateDriverLicenseDate("2016-09-25", "2026-09-26"),
|
||||
).toThrow("بیشتر از ۱۰ سال قبل");
|
||||
});
|
||||
|
||||
it("requires the date only for a licensed driver", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: true,
|
||||
licenseNumber: "123456789",
|
||||
licenseType: "1",
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
}),
|
||||
).toThrow("تاریخ صدور گواهینامه");
|
||||
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
}),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("links several roles to one explicitly shared person", () => {
|
||||
const resolved = resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: true,
|
||||
driverLicenseDate: "1400/01/01",
|
||||
licenseNumber: "123456789",
|
||||
licenseType: "1",
|
||||
},
|
||||
@@ -231,6 +276,7 @@ describe("inquiry participant resolver", () => {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: true,
|
||||
driverLicenseDate: "1400/01/01",
|
||||
licenseNumber: "D-1",
|
||||
licenseType: "1",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user