website refactor
This commit is contained in:
@@ -40,7 +40,8 @@ describe('LeagueService', () => {
|
||||
const result = await service.getAllLeagues();
|
||||
|
||||
expect(mockApiClient.getAllWithCapacityAndScoring).toHaveBeenCalled();
|
||||
expect(result).toEqual(mockDto);
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(result.unwrap()).toEqual(mockDto);
|
||||
});
|
||||
|
||||
it('should handle empty leagues array', async () => {
|
||||
@@ -50,14 +51,17 @@ describe('LeagueService', () => {
|
||||
|
||||
const result = await service.getAllLeagues();
|
||||
|
||||
expect(result).toEqual(mockDto);
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(result.unwrap()).toEqual(mockDto);
|
||||
});
|
||||
|
||||
it('should throw error when apiClient.getAllWithCapacityAndScoring fails', async () => {
|
||||
const error = new Error('API call failed');
|
||||
mockApiClient.getAllWithCapacityAndScoring.mockRejectedValue(error);
|
||||
|
||||
await expect(service.getAllLeagues()).rejects.toThrow('API call failed');
|
||||
const result = await service.getAllLeagues();
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.getError().message).toBe('API call failed');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -192,9 +196,10 @@ describe('LeagueService', () => {
|
||||
|
||||
mockApiClient.create.mockResolvedValue(mockDto);
|
||||
|
||||
await service.createLeague(input);
|
||||
const result = await service.createLeague(input);
|
||||
|
||||
expect(mockApiClient.create).toHaveBeenCalledWith(input);
|
||||
expect(result).toEqual(mockDto);
|
||||
});
|
||||
|
||||
it('should throw error when apiClient.create fails', async () => {
|
||||
|
||||
Reference in New Issue
Block a user