From 100fb3487d8f40ad45150bf800db9e0943aa04b4 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Tue, 2 Apr 2024 11:08:39 +0200 Subject: [PATCH] add possibility to have more than one driver target in carpool path item (eg. when a user adds 2 same waypoints with a different target) --- .../carpool-path-item.value-object.ts | 10 +--------- .../carpool-path-item.value-object.spec.ts | 18 ------------------ 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/modules/ad/core/domain/value-objects/carpool-path-item.value-object.ts b/src/modules/ad/core/domain/value-objects/carpool-path-item.value-object.ts index 377000a..8c5f53d 100644 --- a/src/modules/ad/core/domain/value-objects/carpool-path-item.value-object.ts +++ b/src/modules/ad/core/domain/value-objects/carpool-path-item.value-object.ts @@ -2,8 +2,7 @@ import { ArgumentOutOfRangeException, ValueObject, } from '@mobicoop/ddd-library'; -import { Actor, ActorProps } from './actor.value-object'; -import { Role } from '../ad.types'; +import { ActorProps } from './actor.value-object'; import { Point, PointProps } from './point.value-object'; /** Note: @@ -36,12 +35,5 @@ export class CarpoolPathItem extends ValueObject { }); if (props.actors.length <= 0) throw new ArgumentOutOfRangeException('at least one actor is required'); - if ( - props.actors.filter((actor: Actor) => actor.role == Role.DRIVER).length > - 1 - ) - throw new ArgumentOutOfRangeException( - 'a carpoolStep can contain only one driver', - ); } } diff --git a/src/modules/ad/tests/unit/core/carpool-path-item.value-object.spec.ts b/src/modules/ad/tests/unit/core/carpool-path-item.value-object.spec.ts index 9da4378..ed093d9 100644 --- a/src/modules/ad/tests/unit/core/carpool-path-item.value-object.spec.ts +++ b/src/modules/ad/tests/unit/core/carpool-path-item.value-object.spec.ts @@ -33,22 +33,4 @@ describe('Carpool Path Item value object', () => { }); }).toThrow(ArgumentOutOfRangeException); }); - it('should throw an exception if actors contains more than one driver', () => { - expect(() => { - new CarpoolPathItem({ - lat: 48.689445, - lon: 6.17651, - actors: [ - new Actor({ - role: Role.DRIVER, - target: Target.NEUTRAL, - }), - new Actor({ - role: Role.DRIVER, - target: Target.START, - }), - ], - }); - }).toThrow(ArgumentOutOfRangeException); - }); });