refactor
This commit is contained in:
36
core/racing/domain/entities/Game.test.ts
Normal file
36
core/racing/domain/entities/Game.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Game } from './Game';
|
||||
|
||||
describe('Game', () => {
|
||||
it('should create a game', () => {
|
||||
const game = Game.create({
|
||||
id: 'game1',
|
||||
name: 'iRacing',
|
||||
});
|
||||
|
||||
expect(game.id.toString()).toBe('game1');
|
||||
expect(game.name.toString()).toBe('iRacing');
|
||||
});
|
||||
|
||||
it('should throw on invalid id', () => {
|
||||
expect(() => Game.create({
|
||||
id: '',
|
||||
name: 'iRacing',
|
||||
})).toThrow('Game ID cannot be empty');
|
||||
});
|
||||
|
||||
it('should throw on invalid name', () => {
|
||||
expect(() => Game.create({
|
||||
id: 'game1',
|
||||
name: '',
|
||||
})).toThrow('Game name cannot be empty');
|
||||
});
|
||||
|
||||
it('should throw on name too long', () => {
|
||||
const longName = 'a'.repeat(51);
|
||||
expect(() => Game.create({
|
||||
id: 'game1',
|
||||
name: longName,
|
||||
})).toThrow('Game name cannot exceed 50 characters');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user