refactor
This commit is contained in:
32
core/racing/domain/value-objects/TrackCountry.test.ts
Normal file
32
core/racing/domain/value-objects/TrackCountry.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { TrackCountry } from './TrackCountry';
|
||||
|
||||
describe('TrackCountry', () => {
|
||||
it('should create track country', () => {
|
||||
const country = TrackCountry.create('USA');
|
||||
expect(country.toString()).toBe('USA');
|
||||
expect(country.props).toBe('USA');
|
||||
});
|
||||
|
||||
it('should trim whitespace', () => {
|
||||
const country = TrackCountry.create(' USA ');
|
||||
expect(country.toString()).toBe('USA');
|
||||
});
|
||||
|
||||
it('should throw for empty country', () => {
|
||||
expect(() => TrackCountry.create('')).toThrow('Track country is required');
|
||||
expect(() => TrackCountry.create(' ')).toThrow('Track country is required');
|
||||
});
|
||||
|
||||
it('should equal same countries', () => {
|
||||
const c1 = TrackCountry.create('USA');
|
||||
const c2 = TrackCountry.create('USA');
|
||||
expect(c1.equals(c2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not equal different countries', () => {
|
||||
const c1 = TrackCountry.create('USA');
|
||||
const c2 = TrackCountry.create('UK');
|
||||
expect(c1.equals(c2)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user