2023-05-11 15:47:55 +00:00
|
|
|
import { Route } from '../../domain/entities/route';
|
|
|
|
import { SpacetimePoint } from '../../domain/entities/spacetime-point';
|
2023-04-19 15:32:42 +00:00
|
|
|
|
|
|
|
const mockGeodesic = {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
inverse: jest.fn().mockImplementation((lon1, lat1, lon2, lat2) => {
|
|
|
|
return lon1 == 0
|
|
|
|
? {
|
|
|
|
azimuth: 45,
|
|
|
|
distance: 50000,
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
azimuth: -45,
|
|
|
|
distance: 60000,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Route entity', () => {
|
|
|
|
it('should be defined', () => {
|
|
|
|
const route = new Route(mockGeodesic);
|
|
|
|
expect(route).toBeDefined();
|
|
|
|
});
|
|
|
|
it('should set points and geodesic values for a route', () => {
|
|
|
|
const route = new Route(mockGeodesic);
|
|
|
|
route.setPoints([
|
2023-04-20 13:52:01 +00:00
|
|
|
{
|
|
|
|
lon: 10,
|
|
|
|
lat: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
lon: 20,
|
|
|
|
lat: 20,
|
|
|
|
},
|
2023-04-19 15:32:42 +00:00
|
|
|
]);
|
|
|
|
expect(route.points.length).toBe(2);
|
|
|
|
expect(route.fwdAzimuth).toBe(315);
|
|
|
|
expect(route.backAzimuth).toBe(135);
|
|
|
|
expect(route.distanceAzimuth).toBe(60000);
|
|
|
|
});
|
|
|
|
it('should set spacetimePoints for a route', () => {
|
|
|
|
const route = new Route(mockGeodesic);
|
2023-04-26 10:10:22 +00:00
|
|
|
const spacetimePoint1 = new SpacetimePoint({ lon: 0, lat: 0 }, 0, 0);
|
|
|
|
const spacetimePoint2 = new SpacetimePoint({ lon: 10, lat: 10 }, 500, 5000);
|
2023-04-19 15:32:42 +00:00
|
|
|
route.setSpacetimePoints([spacetimePoint1, spacetimePoint2]);
|
|
|
|
expect(route.spacetimePoints.length).toBe(2);
|
|
|
|
});
|
|
|
|
});
|