45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
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);
|
|
});
|
|
});
|
|
}); |