route tests

This commit is contained in:
sbriat
2023-08-21 17:14:22 +02:00
parent dad964b39c
commit 65dd8d64b1
3 changed files with 69 additions and 15 deletions

View File

@@ -0,0 +1,69 @@
import {
ArgumentInvalidException,
ArgumentOutOfRangeException,
} from '@mobicoop/ddd-library';
import { Waypoint } from '@modules/geography/core/domain/value-objects/waypoint.value-object';
describe('Waypoint value object', () => {
it('should create a waypoint value object', () => {
const waypointVO = new Waypoint({
position: 0,
lon: 48.689445,
lat: 6.17651,
});
expect(waypointVO.position).toBe(0);
expect(waypointVO.lon).toBe(48.689445);
expect(waypointVO.lat).toBe(6.17651);
});
it('should throw an exception if position is invalid', () => {
try {
new Waypoint({
position: -1,
lon: 48.689445,
lat: 6.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentInvalidException);
}
});
it('should throw an exception if longitude is invalid', () => {
try {
new Waypoint({
position: 0,
lon: 348.689445,
lat: 6.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
new Waypoint({
position: 0,
lon: -348.689445,
lat: 6.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
});
it('should throw an exception if longitude is invalid', () => {
try {
new Waypoint({
position: 0,
lon: 48.689445,
lat: 96.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
new Waypoint({
position: 0,
lon: 48.689445,
lat: -96.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
});
});