mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 13:52:40 +00:00
add direction decoder
This commit is contained in:
@@ -112,7 +112,12 @@ export class AdMapper
|
||||
driverDistance: record.driverDistance,
|
||||
passengerDuration: record.passengerDuration,
|
||||
passengerDistance: record.passengerDistance,
|
||||
waypoints: [],
|
||||
waypoints: this.directionEncoder
|
||||
.decode(record.waypoints)
|
||||
.map((coordinates, index) => ({
|
||||
position: index,
|
||||
...coordinates,
|
||||
})),
|
||||
fwdAzimuth: record.fwdAzimuth,
|
||||
backAzimuth: record.backAzimuth,
|
||||
},
|
||||
|
||||
@@ -92,6 +92,16 @@ const mockDirectionEncoder: DirectionEncoderPort = {
|
||||
() =>
|
||||
"'LINESTRING(6.1765102 48.689445,4.984578 48.725687,2.3522 48.8566)'",
|
||||
),
|
||||
decode: jest.fn().mockImplementation(() => [
|
||||
{
|
||||
lon: 6.1765102,
|
||||
lat: 48.689445,
|
||||
},
|
||||
{
|
||||
lon: 2.3522,
|
||||
lat: 48.8566,
|
||||
},
|
||||
]),
|
||||
};
|
||||
|
||||
const mockRouteProvider: RouteProviderPort = {
|
||||
@@ -161,6 +171,7 @@ describe('Ad Mapper', () => {
|
||||
const mapped: AdEntity = adMapper.toDomain(adReadModel);
|
||||
expect(mapped.getProps().schedule.length).toBe(1);
|
||||
expect(mapped.getProps().schedule[0].time).toBe('07:05');
|
||||
expect(mapped.getProps().waypoints.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should map domain entity to response', async () => {
|
||||
|
||||
@@ -16,6 +16,7 @@ const mockMessagePublisher = {
|
||||
|
||||
const mockDirectionEncoder: DirectionEncoderPort = {
|
||||
encode: jest.fn(),
|
||||
decode: jest.fn(),
|
||||
};
|
||||
|
||||
const mockRouteProvider: RouteProviderPort = {
|
||||
|
||||
Reference in New Issue
Block a user