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