forked from Yara724/api
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import {
|
|
selectAccidentVehicleUsedId,
|
|
vehicleGroupIdForKind,
|
|
} from "./fanavaran-accident-vehicle-used";
|
|
|
|
describe("selectAccidentVehicleUsedId", () => {
|
|
const useTypes = [
|
|
{ Id: 1, Caption: "شخصي", IsActive: 1, VehicleGroupId: 1 },
|
|
{ Id: 3, Caption: "تاکسي درون شهري", IsActive: 1, VehicleGroupId: 1 },
|
|
{ Id: 35, Caption: "آمبولانس", IsActive: 1, VehicleGroupId: 2 },
|
|
{ Id: 36, Caption: "حمل مواد سريع الاشتعال", IsActive: 1, VehicleGroupId: 3 },
|
|
];
|
|
|
|
const kinds = [
|
|
{ Id: 8671, VehicleGroupId: 1, IsActive: 1 },
|
|
{ Id: 5904, VehicleGroupId: 3, IsActive: 1 },
|
|
];
|
|
|
|
it("keeps preferred id 1 when the car is passenger group 1", () => {
|
|
expect(vehicleGroupIdForKind(kinds, 8671)).toBe(1);
|
|
expect(selectAccidentVehicleUsedId(useTypes, 1, 1)).toBe(1);
|
|
});
|
|
|
|
it("keeps the vehicle UsedId when it is valid for that group", () => {
|
|
expect(selectAccidentVehicleUsedId(useTypes, 3, 36)).toBe(36);
|
|
});
|
|
|
|
it("picks an active use type for a non-passenger group instead of 1", () => {
|
|
expect(vehicleGroupIdForKind(kinds, 5904)).toBe(3);
|
|
expect(selectAccidentVehicleUsedId(useTypes, 3, 1)).toBe(36);
|
|
});
|
|
|
|
it("falls back to the vehicle UsedId when group is unknown", () => {
|
|
expect(selectAccidentVehicleUsedId(useTypes, null, 84)).toBe(84);
|
|
});
|
|
});
|