core tests
Some checks failed
Some checks failed
This commit is contained in:
@@ -4,8 +4,8 @@ export class Position {
|
||||
private constructor(private readonly value: number) {}
|
||||
|
||||
static create(value: number): Position {
|
||||
if (!Number.isInteger(value) || value < 0) {
|
||||
throw new RacingDomainValidationError('Position must be a non-negative integer');
|
||||
if (!Number.isInteger(value) || value <= 0) {
|
||||
throw new RacingDomainValidationError('Position must be a positive integer');
|
||||
}
|
||||
return new Position(value);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ describe('Result', () => {
|
||||
fastestLap: validFastestLap,
|
||||
incidents: validIncidents,
|
||||
startPosition: validStartPosition,
|
||||
points: 10,
|
||||
};
|
||||
|
||||
const result = Result.create(props);
|
||||
@@ -37,6 +38,7 @@ describe('Result', () => {
|
||||
expect(result.fastestLap.toNumber()).toBe(validFastestLap);
|
||||
expect(result.incidents.toNumber()).toBe(validIncidents);
|
||||
expect(result.startPosition.toNumber()).toBe(validStartPosition);
|
||||
expect(result.points).toBe(10);
|
||||
});
|
||||
|
||||
it('should throw error for empty id', () => {
|
||||
@@ -48,6 +50,7 @@ describe('Result', () => {
|
||||
fastestLap: validFastestLap,
|
||||
incidents: validIncidents,
|
||||
startPosition: validStartPosition,
|
||||
points: 10,
|
||||
};
|
||||
|
||||
expect(() => Result.create(props)).toThrow(RacingDomainValidationError);
|
||||
@@ -62,6 +65,7 @@ describe('Result', () => {
|
||||
fastestLap: validFastestLap,
|
||||
incidents: validIncidents,
|
||||
startPosition: validStartPosition,
|
||||
points: 10,
|
||||
};
|
||||
|
||||
expect(() => Result.create(props)).toThrow(RacingDomainValidationError);
|
||||
|
||||
Reference in New Issue
Block a user