diff --git a/src/modules/geography/core/domain/route.types.ts b/src/modules/geography/core/domain/route.types.ts index 1df57c9..74d1c6c 100644 --- a/src/modules/geography/core/domain/route.types.ts +++ b/src/modules/geography/core/domain/route.types.ts @@ -43,7 +43,6 @@ export type Path = { export type Point = { lon: number; lat: number; - context?: PointContext; }; export type SpacetimePoint = Point & { @@ -56,14 +55,6 @@ export enum Role { PASSENGER = 'PASSENGER', } -export enum PointContext { - HOUSE_NUMBER = 'HOUSE_NUMBER', - STREET_ADDRESS = 'STREET_ADDRESS', - LOCALITY = 'LOCALITY', - VENUE = 'VENUE', - OTHER = 'OTHER', -} - export enum PathType { GENERIC = 'generic', DRIVER = 'driver', diff --git a/src/modules/geography/core/domain/value-objects/waypoint.value-object.ts b/src/modules/geography/core/domain/value-objects/waypoint.value-object.ts index 9f6b493..353f51d 100644 --- a/src/modules/geography/core/domain/value-objects/waypoint.value-object.ts +++ b/src/modules/geography/core/domain/value-objects/waypoint.value-object.ts @@ -3,7 +3,6 @@ import { ArgumentOutOfRangeException, ValueObject, } from '@mobicoop/ddd-library'; -import { PointContext } from '../route.types'; /** Note: * Value Objects with multiple properties can contain @@ -14,7 +13,6 @@ export interface WaypointProps { position: number; lon: number; lat: number; - context?: PointContext; } export class Waypoint extends ValueObject { @@ -30,10 +28,6 @@ export class Waypoint extends ValueObject { return this.props.lat; } - get context(): PointContext { - return this.props.context; - } - protected validate(props: WaypointProps): void { if (props.position < 0) throw new ArgumentInvalidException( diff --git a/src/modules/geography/tests/unit/core/waypoint.value-object.spec.ts b/src/modules/geography/tests/unit/core/waypoint.value-object.spec.ts new file mode 100644 index 0000000..e69c1d2 --- /dev/null +++ b/src/modules/geography/tests/unit/core/waypoint.value-object.spec.ts @@ -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); + } + }); +});