refactor
This commit is contained in:
38
core/racing/domain/entities/LeagueScoringConfigId.test.ts
Normal file
38
core/racing/domain/entities/LeagueScoringConfigId.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { LeagueScoringConfigId } from './LeagueScoringConfigId';
|
||||
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
||||
|
||||
describe('LeagueScoringConfigId', () => {
|
||||
describe('create', () => {
|
||||
it('should create a LeagueScoringConfigId with valid value', () => {
|
||||
const id = LeagueScoringConfigId.create('scoring-config-123');
|
||||
expect(id.toString()).toBe('scoring-config-123');
|
||||
});
|
||||
|
||||
it('should trim whitespace', () => {
|
||||
const id = LeagueScoringConfigId.create(' scoring-config-123 ');
|
||||
expect(id.toString()).toBe('scoring-config-123');
|
||||
});
|
||||
|
||||
it('should throw error for empty string', () => {
|
||||
expect(() => LeagueScoringConfigId.create('')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
|
||||
it('should throw error for whitespace only', () => {
|
||||
expect(() => LeagueScoringConfigId.create(' ')).toThrow(RacingDomainValidationError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('equals', () => {
|
||||
it('should return true for equal ids', () => {
|
||||
const id1 = LeagueScoringConfigId.create('scoring-config-123');
|
||||
const id2 = LeagueScoringConfigId.create('scoring-config-123');
|
||||
expect(id1.equals(id2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for different ids', () => {
|
||||
const id1 = LeagueScoringConfigId.create('scoring-config-123');
|
||||
const id2 = LeagueScoringConfigId.create('scoring-config-456');
|
||||
expect(id1.equals(id2)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user