refactor
This commit is contained in:
44
core/racing/domain/entities/result/Position.test.ts
Normal file
44
core/racing/domain/entities/result/Position.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Position } from './Position';
|
||||
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
|
||||
|
||||
describe('Position', () => {
|
||||
describe('create', () => {
|
||||
it('should create a Position with valid positive integer', () => {
|
||||
const position = Position.create(1);
|
||||
expect(position.toNumber()).toBe(1);
|
||||
});
|
||||
|
||||
it('should throw error for zero', () => {
|
||||
expect(() => Position.create(0)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw error for negative number', () => {
|
||||
expect(() => Position.create(-1)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw error for non-integer', () => {
|
||||
expect(() => Position.create(1.5)).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toNumber', () => {
|
||||
it('should return the number value', () => {
|
||||
const position = Position.create(5);
|
||||
expect(position.toNumber()).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', () => {
|
||||
it('should return true for equal positions', () => {
|
||||
const pos1 = Position.create(2);
|
||||
const pos2 = Position.create(2);
|
||||
expect(pos1.equals(pos2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for different positions', () => {
|
||||
const pos1 = Position.create(2);
|
||||
const pos2 = Position.create(3);
|
||||
expect(pos1.equals(pos2)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user