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)
This commit is contained in:
parent
e501bef249
commit
100fb3487d
|
@ -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<CarpoolPathItemProps> {
|
|||
});
|
||||
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',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue