refactor
This commit is contained in:
38
core/racing/domain/entities/penalty/PenaltyReason.test.ts
Normal file
38
core/racing/domain/entities/penalty/PenaltyReason.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { PenaltyReason } from './PenaltyReason';
|
||||
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
|
||||
|
||||
describe('PenaltyReason', () => {
|
||||
describe('create', () => {
|
||||
it('should create a PenaltyReason with valid value', () => {
|
||||
const reason = PenaltyReason.create('Speeding in pit lane');
|
||||
expect(reason.toString()).toBe('Speeding in pit lane');
|
||||
});
|
||||
|
||||
it('should trim whitespace', () => {
|
||||
const reason = PenaltyReason.create(' Speeding in pit lane ');
|
||||
expect(reason.toString()).toBe('Speeding in pit lane');
|
||||
});
|
||||
|
||||
it('should throw error for empty string', () => {
|
||||
expect(() => PenaltyReason.create('')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw error for whitespace only', () => {
|
||||
expect(() => PenaltyReason.create(' ')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', () => {
|
||||
it('should return true for equal reasons', () => {
|
||||
const reason1 = PenaltyReason.create('Speeding');
|
||||
const reason2 = PenaltyReason.create('Speeding');
|
||||
expect(reason1.equals(reason2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for different reasons', () => {
|
||||
const reason1 = PenaltyReason.create('Speeding');
|
||||
const reason2 = PenaltyReason.create('Cutting');
|
||||
expect(reason1.equals(reason2)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user