refactor
This commit is contained in:
32
core/racing/domain/value-objects/TrackName.test.ts
Normal file
32
core/racing/domain/value-objects/TrackName.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } 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.props).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 is required');
|
||||
expect(() => TrackName.create(' ')).toThrow('Track name is required');
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user