-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getAvailableVehicleTypes util function
- Loading branch information
1 parent
04ea870
commit 3f03301
Showing
6 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CaptureAppConfig, VehicleType } from '@monkvision/types'; | ||
import { uniq } from './array.utils'; | ||
|
||
/** | ||
* Util function used to extract the list of available vehicle types in a CaptureAppConfig object. | ||
*/ | ||
export function getAvailableVehicleTypes(config: CaptureAppConfig): VehicleType[] { | ||
return ( | ||
config.enableSteeringWheelPosition | ||
? uniq([...Object.keys(config.sights.left), ...Object.keys(config.sights.right)]) | ||
: Object.keys(config.sights) | ||
) as VehicleType[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { CaptureAppConfig, SteeringWheelPosition, VehicleType } from '@monkvision/types'; | ||
import { getAvailableVehicleTypes } from '../../src'; | ||
|
||
describe('Config utils', () => { | ||
describe('getAvailableVehicleTypes function', () => { | ||
it('should return the list of available vehicle types in non-steering wheel sights', () => { | ||
const config = { | ||
enableSteeringWheelPosition: false, | ||
sights: { [VehicleType.SEDAN]: [], [VehicleType.HGV]: [] }, | ||
} as unknown as CaptureAppConfig; | ||
expect(getAvailableVehicleTypes(config)).toEqual([VehicleType.SEDAN, VehicleType.HGV]); | ||
}); | ||
|
||
it('should return the list of available vehicle types in steering wheel enabled sights', () => { | ||
const config = { | ||
enableSteeringWheelPosition: true, | ||
sights: { | ||
[SteeringWheelPosition.LEFT]: { [VehicleType.VAN]: [], [VehicleType.CITY]: [] }, | ||
[SteeringWheelPosition.RIGHT]: { [VehicleType.VAN]: [], [VehicleType.CITY]: [] }, | ||
}, | ||
} as unknown as CaptureAppConfig; | ||
expect(getAvailableVehicleTypes(config)).toEqual([VehicleType.VAN, VehicleType.CITY]); | ||
}); | ||
|
||
it('should return the list of available vehicle types in steering wheel enabled sights with different sights for each side', () => { | ||
const config = { | ||
enableSteeringWheelPosition: true, | ||
sights: { | ||
[SteeringWheelPosition.LEFT]: { [VehicleType.VAN]: [], [VehicleType.LARGE_SUV]: [] }, | ||
[SteeringWheelPosition.RIGHT]: { [VehicleType.VAN]: [], [VehicleType.HATCHBACK]: [] }, | ||
}, | ||
} as unknown as CaptureAppConfig; | ||
expect(getAvailableVehicleTypes(config)).toEqual([ | ||
VehicleType.VAN, | ||
VehicleType.LARGE_SUV, | ||
VehicleType.HATCHBACK, | ||
]); | ||
}); | ||
}); | ||
}); |