/* eslint-disable @typescript-eslint/naming-convention */ import { buildVehiclePartial, DEFAULT_VEHICLE_BODY, VehiclePartialInput, } from '../../../../../models/Core/partials/personalVehicle'; describe('personalVehicle partial', () => { it('should return [] for no input', () => { // given const input = {}; // then expect(buildVehiclePartial(input)) .toEqual([]); }); it('should return DEFAULT_VEHICLE_BODY if no current vehicle supplied', () => { // given const input = { update: {}, }; // then expect(buildVehiclePartial(input)) .toEqual([{ ...DEFAULT_VEHICLE_BODY }]); }); it('should return updated vehicle if update vehicle supplied', () => { // given const input = { update: { year: '2021', brand: 'ACURA', model: 'MDX', fuelType: 'Benzyna', engineCapacity: 3664, bodyType: 'Kombi', doors: 5, version: 'MDX 3.7 V6 Base', usage: 'Prywatny', insuredSum: 158000, coreHorsePower: 300, coreLength: 4844, coreWeight: 0, seats: 5, coreFuelType: { name: 'petrol', isLpg: false }, vehicleType: 'passenger_car', euroTaxCarData: { source: 'eurotax', selected: true, amount: { currency: 'pln', amount: 78200.00, }, externalSystemID: '12345616', }, infoExpertCarData: { source: 'info_expert', selected: false, amount: { currency: 'pln', amount: 10, }, externalSystemID: 'infoexpert-12345', }, }, } as unknown as VehiclePartialInput; // then expect(buildVehiclePartial(input)) .toEqual([ { ...DEFAULT_VEHICLE_BODY, make: 'ACURA', model: 'MDX', year: 2021, vehicleType_SKY: 'passenger_car', fuelType_SKY: 'petrol', LPG_SKY: false, keysNumber_SKY: 2, costNew: { amount: 158000 }, bodyType_SKY: 'Kombi', version_SKY: 'MDX 3.7 V6 Base', enginePower_SKY: 300, engineCapacity_SKY: 3664, doorCount_SKY: 5, vehicleLength_SKY: 4844, vehicleWeight_SKY: 0, seatsNumber_SKY: 5, vehicleValues: [{ source: 'eurotax', selected: true, amount: { currency: 'pln', amount: 78200.00, }, externalSystemID: '12345616', }, { source: 'info_expert', selected: false, amount: { currency: 'pln', amount: 10, }, externalSystemID: 'infoexpert-12345', }], }, ]); }); it('should update vehicle value fields if value provided', () => { // given const UPDATED_VALUE = 10000; const input = { update: { insuredSum: UPDATED_VALUE, }, }; // then const expected = { costNew: { amount: UPDATED_VALUE, }, }; expect(buildVehiclePartial(input)) .toEqual([ expect.objectContaining(expected), ]); }); });