refactor
This commit is contained in:
42
core/racing/domain/entities/penalty/PenaltyStatus.test.ts
Normal file
42
core/racing/domain/entities/penalty/PenaltyStatus.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { PenaltyStatus } from './PenaltyStatus';
|
||||
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
|
||||
|
||||
describe('PenaltyStatus', () => {
|
||||
describe('create', () => {
|
||||
it('should create a PenaltyStatus with valid value', () => {
|
||||
const status = PenaltyStatus.create('pending');
|
||||
expect(status.toString()).toBe('pending');
|
||||
});
|
||||
|
||||
it('should create all valid statuses', () => {
|
||||
const validStatuses = ['pending', 'applied', 'appealed', 'overturned'];
|
||||
|
||||
validStatuses.forEach(statusValue => {
|
||||
const status = PenaltyStatus.create(statusValue);
|
||||
expect(status.toString()).toBe(statusValue);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw error for invalid status', () => {
|
||||
expect(() => PenaltyStatus.create('invalid_status')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw error for empty string', () => {
|
||||
expect(() => PenaltyStatus.create('')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', () => {
|
||||
it('should return true for equal statuses', () => {
|
||||
const status1 = PenaltyStatus.create('pending');
|
||||
const status2 = PenaltyStatus.create('pending');
|
||||
expect(status1.equals(status2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for different statuses', () => {
|
||||
const status1 = PenaltyStatus.create('pending');
|
||||
const status2 = PenaltyStatus.create('applied');
|
||||
expect(status1.equals(status2)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user