Files
gridpilot.gg/core/racing/domain/entities/penalty/PenaltyId.test.ts
2025-12-17 00:33:13 +01:00

38 lines
1.2 KiB
TypeScript

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