refactor
This commit is contained in:
34
core/racing/domain/value-objects/driver/DriverName.test.ts
Normal file
34
core/racing/domain/value-objects/driver/DriverName.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user