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