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