Files
gridpilot.gg/core/racing/domain/value-objects/TrackName.test.ts
2026-01-16 19:46:49 +01:00

32 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { TrackName } from './TrackName';
describe('TrackName', () => {
it('should create track name', () => {
const name = TrackName.create('Silverstone');
expect(name.toString()).toBe('Silverstone');
expect(name.value).toBe('Silverstone');
});
it('should trim whitespace', () => {
const name = TrackName.create(' Silverstone ');
expect(name.toString()).toBe('Silverstone');
});
it('should throw for empty name', () => {
expect(() => TrackName.create('')).toThrow('Track name cannot be empty');
expect(() => TrackName.create(' ')).toThrow('Track name cannot be empty');
});
it('should equal same names', () => {
const n1 = TrackName.create('Silverstone');
const n2 = TrackName.create('Silverstone');
expect(n1.equals(n2)).toBe(true);
});
it('should not equal different names', () => {
const n1 = TrackName.create('Silverstone');
const n2 = TrackName.create('Monza');
expect(n1.equals(n2)).toBe(false);
});
});