refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
|
||||
import { CreateLeagueWithSeasonAndScoringUseCase } from './CreateLeagueWithSeasonAndScoringUseCase';
|
||||
import type { CreateLeagueWithSeasonAndScoringCommand } from './CreateLeagueWithSeasonAndScoringCommand';
|
||||
import type { CreateLeagueWithSeasonAndScoringCommand } from './CreateLeagueWithSeasonAndScoringUseCase';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
|
||||
import type { ILeagueScoringConfigRepository } from '../../domain/repositories/ILeagueScoringConfigRepository';
|
||||
@@ -114,7 +114,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('League name is required');
|
||||
expect(result.unwrapErr().details.message).toBe('League name is required');
|
||||
});
|
||||
|
||||
it('should return error when ownerId is empty', async () => {
|
||||
@@ -133,7 +133,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command as CreateLeagueWithSeasonAndScoringCommand);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('League ownerId is required');
|
||||
expect(result.unwrapErr().details.message).toBe('League ownerId is required');
|
||||
});
|
||||
|
||||
it('should return error when gameId is empty', async () => {
|
||||
@@ -152,7 +152,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('gameId is required');
|
||||
expect(result.unwrapErr().details.message).toBe('gameId is required');
|
||||
});
|
||||
|
||||
it('should return error when visibility is missing', async () => {
|
||||
@@ -166,10 +166,10 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
enableTrophyChampionship: false,
|
||||
};
|
||||
|
||||
const result = await useCase.execute(command);
|
||||
const result = await useCase.execute(command as CreateLeagueWithSeasonAndScoringCommand);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('visibility is required');
|
||||
expect(result.unwrapErr().details.message).toBe('visibility is required');
|
||||
});
|
||||
|
||||
it('should return error when maxDrivers is invalid', async () => {
|
||||
@@ -189,7 +189,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('maxDrivers must be greater than 0 when provided');
|
||||
expect(result.unwrapErr().details.message).toBe('maxDrivers must be greater than 0 when provided');
|
||||
});
|
||||
|
||||
it('should return error when ranked league has insufficient drivers', async () => {
|
||||
@@ -209,7 +209,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toContain('Ranked leagues require at least 10 drivers');
|
||||
expect(result.unwrapErr().details.message).toContain('Ranked leagues require at least 10 drivers');
|
||||
});
|
||||
|
||||
it('should return error when scoring preset is unknown', async () => {
|
||||
@@ -231,7 +231,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('Unknown scoring preset: unknown-preset');
|
||||
expect(result.unwrapErr().details.message).toBe('Unknown scoring preset: unknown-preset');
|
||||
});
|
||||
|
||||
it('should return error when repository throws', async () => {
|
||||
@@ -259,6 +259,6 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => {
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().message).toBe('DB error');
|
||||
expect(result.unwrapErr().details.message).toBe('DB error');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user