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

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { DriverName } from './DriverName';
describe('DriverName', () => {
it('should create a driver name', () => {
const name = DriverName.create('John Doe');
expect(name.toString()).toBe('John Doe');
});
it('should trim whitespace', () => {
const name = DriverName.create(' John Doe ');
expect(name.toString()).toBe('John Doe');
});
it('should throw on empty name', () => {
expect(() => DriverName.create('')).toThrow('Driver name is required');
});
it('should throw on whitespace only', () => {
expect(() => DriverName.create(' ')).toThrow('Driver name is required');
});
it('should equal same name', () => {
const n1 = DriverName.create('John Doe');
const n2 = DriverName.create('John Doe');
expect(n1.equals(n2)).toBe(true);
});
it('should not equal different name', () => {
const n1 = DriverName.create('John Doe');
const n2 = DriverName.create('Jane Doe');
expect(n1.equals(n2)).toBe(false);
});
});