59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { RouteEntity } from '@modules/geography/core/domain/route.entity';
|
|
import { RouteMapper } from '@modules/geography/route.mapper';
|
|
import { Test } from '@nestjs/testing';
|
|
|
|
describe('Route Mapper', () => {
|
|
let routeMapper: RouteMapper;
|
|
|
|
beforeAll(async () => {
|
|
const module = await Test.createTestingModule({
|
|
providers: [RouteMapper],
|
|
}).compile();
|
|
routeMapper = module.get<RouteMapper>(RouteMapper);
|
|
});
|
|
|
|
it('should be defined', () => {
|
|
expect(routeMapper).toBeDefined();
|
|
});
|
|
|
|
it('should map domain entity to persistence data', async () => {
|
|
expect(routeMapper.toPersistence()).toBeUndefined();
|
|
});
|
|
|
|
it('should map persisted data to domain entity', async () => {
|
|
expect(routeMapper.toDomain()).toBeUndefined();
|
|
});
|
|
|
|
it('should map domain entity to response', async () => {
|
|
const now = new Date();
|
|
const routeEntity: RouteEntity = new RouteEntity({
|
|
id: '047a6ecf-23d4-4d3e-877c-3225d560a8da',
|
|
createdAt: now,
|
|
updatedAt: now,
|
|
props: {
|
|
driverDistance: 23000,
|
|
driverDuration: 900,
|
|
passengerDistance: 23000,
|
|
passengerDuration: 900,
|
|
fwdAzimuth: 283,
|
|
backAzimuth: 93,
|
|
distanceAzimuth: 19840,
|
|
spacetimePoints: [],
|
|
waypoints: [
|
|
{
|
|
position: 0,
|
|
lon: 6.1765103,
|
|
lat: 48.689446,
|
|
},
|
|
{
|
|
position: 1,
|
|
lon: 2.3523,
|
|
lat: 48.8567,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
expect(routeMapper.toResponse(routeEntity).driverDistance).toBe(23000);
|
|
});
|
|
});
|