forked from Yara724/api
fixed default values
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
collectPartyVinCandidates,
|
||||
fanavaranIdOrConfigDefault,
|
||||
filterPoliciesByLine,
|
||||
insuranceLineLabel,
|
||||
parseLastCarPolicyInput,
|
||||
@@ -172,6 +173,12 @@ describe("fanavaran last car policy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses tenant config default when the API id is missing", () => {
|
||||
expect(fanavaranIdOrConfigDefault(15, 8)).toBe(15);
|
||||
expect(fanavaranIdOrConfigDefault(null, 8)).toBe(8);
|
||||
expect(fanavaranIdOrConfigDefault(0, 10)).toBe(10);
|
||||
});
|
||||
|
||||
it("matches VIN against ChassisNo when VIN is empty", () => {
|
||||
expect(
|
||||
vehicleMatchesCar(
|
||||
|
||||
@@ -162,6 +162,14 @@ export function parseFanavaranId(value: unknown): number | null {
|
||||
return Number.isFinite(id) && id > 0 ? id : null;
|
||||
}
|
||||
|
||||
/** Live Fanavaran / cache id wins; tenant `fanavaranClientConfigs.defaults` if the API returned nothing. */
|
||||
export function fanavaranIdOrConfigDefault(
|
||||
resolved: unknown,
|
||||
configDefault: number,
|
||||
): number {
|
||||
return parseFanavaranId(resolved) ?? configDefault;
|
||||
}
|
||||
|
||||
export function asObjectRecord(value: unknown): Record<string, unknown> | null {
|
||||
if (!value || typeof value !== "object") {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user