update the lookups list

This commit is contained in:
2026-09-07 15:08:08 +03:30
parent 80e112f09b
commit c7cd9e8ce5
11 changed files with 1161 additions and 72 deletions

View File

@@ -0,0 +1,61 @@
import {
asPartyInquiryRows,
parseJalaliDateParts,
pickPersonBirthday,
pickPersonNationalCode,
selectFanavaranDriverId,
} from "./fanavaran-driver-inquiry";
describe("selectFanavaranDriverId", () => {
const rows = [
{ Id: 10, RoleId: 161, Name: "insurer" },
{ Id: 20, RoleId: 166, Name: "driver" },
];
it("prefers insurer role 161 when the driver is the owner", () => {
expect(selectFanavaranDriverId(rows, true)).toBe(10);
});
it("prefers driver role 166 when the driver is not the owner", () => {
expect(selectFanavaranDriverId(rows, false)).toBe(20);
});
it("uses the other role when the preferred role is missing", () => {
expect(selectFanavaranDriverId([{ Id: 20, RoleId: 166 }], true)).toBe(20);
});
it("unwraps a wrapped Fanavaran payload", () => {
expect(selectFanavaranDriverId({ value: rows }, true)).toBe(10);
});
});
describe("pickPersonNationalCode / birthday", () => {
it("uses insurer national code when driverIsInsurer", () => {
expect(
pickPersonNationalCode({
driverIsInsurer: true,
nationalCodeOfInsurer: "0012345678",
nationalCodeOfDriver: "",
}),
).toBe("0012345678");
});
it("falls back across birthday fields", () => {
expect(
pickPersonBirthday({
driverBirthday: null,
birthday: "13480313",
}),
).toBe("13480313");
});
});
describe("asPartyInquiryRows", () => {
it("parses compact Jalali birthday 13480313", () => {
expect(parseJalaliDateParts("13480313")).toEqual({
year: 1348,
month: 3,
day: 13,
});
});
});