refactor
This commit is contained in:
27
core/racing/domain/value-objects/TrackLength.test.ts
Normal file
27
core/racing/domain/value-objects/TrackLength.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { TrackLength } from './TrackLength';
|
||||
|
||||
describe('TrackLength', () => {
|
||||
it('should create track length', () => {
|
||||
const length = TrackLength.create(1000);
|
||||
expect(length.toNumber()).toBe(1000);
|
||||
expect(length.props).toBe(1000);
|
||||
});
|
||||
|
||||
it('should throw for non-positive length', () => {
|
||||
expect(() => TrackLength.create(0)).toThrow('Track length must be positive');
|
||||
expect(() => TrackLength.create(-1)).toThrow('Track length must be positive');
|
||||
});
|
||||
|
||||
it('should equal same lengths', () => {
|
||||
const l1 = TrackLength.create(1000);
|
||||
const l2 = TrackLength.create(1000);
|
||||
expect(l1.equals(l2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not equal different lengths', () => {
|
||||
const l1 = TrackLength.create(1000);
|
||||
const l2 = TrackLength.create(2000);
|
||||
expect(l1.equals(l2)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user