38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { PrizeId } from './PrizeId';
|
|
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
|
|
|
|
describe('PrizeId', () => {
|
|
describe('create', () => {
|
|
it('should create a PrizeId with valid value', () => {
|
|
const id = PrizeId.create('prize-123');
|
|
expect(id.toString()).toBe('prize-123');
|
|
});
|
|
|
|
it('should trim whitespace', () => {
|
|
const id = PrizeId.create(' prize-123 ');
|
|
expect(id.toString()).toBe('prize-123');
|
|
});
|
|
|
|
it('should throw error for empty string', () => {
|
|
expect(() => PrizeId.create('')).toThrow(RacingDomainValidationError);
|
|
});
|
|
|
|
it('should throw error for whitespace only', () => {
|
|
expect(() => PrizeId.create(' ')).toThrow(RacingDomainValidationError);
|
|
});
|
|
});
|
|
|
|
describe('equals', () => {
|
|
it('should return true for equal ids', () => {
|
|
const id1 = PrizeId.create('prize-123');
|
|
const id2 = PrizeId.create('prize-123');
|
|
expect(id1.equals(id2)).toBe(true);
|
|
});
|
|
|
|
it('should return false for different ids', () => {
|
|
const id1 = PrizeId.create('prize-123');
|
|
const id2 = PrizeId.create('prize-456');
|
|
expect(id1.equals(id2)).toBe(false);
|
|
});
|
|
});
|
|
}); |