refactor
This commit is contained in:
33
core/racing/domain/entities/championship/Position.test.ts
Normal file
33
core/racing/domain/entities/championship/Position.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user