31 lines
920 B
TypeScript
31 lines
920 B
TypeScript
|
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)'");
|
||
|
});
|
||
|
});
|