Files
gridpilot.gg/core/racing/domain/value-objects/TrackLength.test.ts
2026-01-16 19:46:49 +01:00

27 lines
874 B
TypeScript

import { describe, expect, it } 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);
});
});