mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 07:52:41 +00:00
tests and refactor for ad geography
This commit is contained in:
8
src/modules/geography/tests/unit/coordinate.spec.ts
Normal file
8
src/modules/geography/tests/unit/coordinate.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Coordinate } from '../../domain/entities/coordinate';
|
||||
|
||||
describe('Coordinate entity', () => {
|
||||
it('should be defined', () => {
|
||||
const coordinate: Coordinate = new Coordinate(6, 47);
|
||||
expect(coordinate).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { PostgresDirectionEncoder } from '../../adapters/secondaries/postgres-direction-encoder';
|
||||
import { Coordinate } from '../../domain/entities/coordinate';
|
||||
|
||||
describe('Postgres direction encoder', () => {
|
||||
it('should be defined', () => {
|
||||
const postgresDirectionEncoder: PostgresDirectionEncoder =
|
||||
new PostgresDirectionEncoder();
|
||||
expect(postgresDirectionEncoder).toBeDefined();
|
||||
});
|
||||
it('should encode coordinates to a postgres direction', () => {
|
||||
const postgresDirectionEncoder: PostgresDirectionEncoder =
|
||||
new PostgresDirectionEncoder();
|
||||
const coordinates: Coordinate[] = [
|
||||
{
|
||||
lon: 6,
|
||||
lat: 47,
|
||||
},
|
||||
{
|
||||
lon: 6.1,
|
||||
lat: 47.1,
|
||||
},
|
||||
{
|
||||
lon: 6.2,
|
||||
lat: 47.2,
|
||||
},
|
||||
];
|
||||
const direction = postgresDirectionEncoder.encode(coordinates);
|
||||
expect(direction).toBe("'LINESTRING(6 47,6.1 47.1,6.2 47.2)'");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user