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