Files
gridpilot.gg/core/racing/domain/entities/championship/Position.test.ts
2025-12-17 00:33:13 +01:00

33 lines
1006 B
TypeScript

import { describe, it, expect } from 'vitest';
import { Position } from './Position';
describe('Position', () => {
it('should create position', () => {
const position = Position.create(1);
expect(position.toNumber()).toBe(1);
});
it('should not create zero position', () => {
expect(() => Position.create(0)).toThrow('Position must be a positive integer');
});
it('should not create negative position', () => {
expect(() => Position.create(-1)).toThrow('Position must be a positive integer');
});
it('should not create non-integer position', () => {
expect(() => Position.create(1.5)).toThrow('Position must be a positive integer');
});
it('should equal same position', () => {
const p1 = Position.create(2);
const p2 = Position.create(2);
expect(p1.equals(p2)).toBe(true);
});
it('should not equal different position', () => {
const p1 = Position.create(2);
const p2 = Position.create(3);
expect(p1.equals(p2)).toBe(false);
});
});