refactor
This commit is contained in:
34
core/racing/domain/value-objects/CarId.test.ts
Normal file
34
core/racing/domain/value-objects/CarId.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CarId } from './CarId';
|
||||
|
||||
describe('CarId', () => {
|
||||
it('should create a car id', () => {
|
||||
const id = CarId.create('car1');
|
||||
expect(id.toString()).toBe('car1');
|
||||
});
|
||||
|
||||
it('should throw on empty id', () => {
|
||||
expect(() => CarId.create('')).toThrow('Car ID cannot be empty');
|
||||
});
|
||||
|
||||
it('should throw on whitespace id', () => {
|
||||
expect(() => CarId.create(' ')).toThrow('Car ID cannot be empty');
|
||||
});
|
||||
|
||||
it('should trim whitespace', () => {
|
||||
const id = CarId.create(' car1 ');
|
||||
expect(id.toString()).toBe('car1');
|
||||
});
|
||||
|
||||
it('should equal same id', () => {
|
||||
const id1 = CarId.create('car1');
|
||||
const id2 = CarId.create('car1');
|
||||
expect(id1.equals(id2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not equal different id', () => {
|
||||
const id1 = CarId.create('car1');
|
||||
const id2 = CarId.create('car2');
|
||||
expect(id1.equals(id2)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user