refactor use cases
This commit is contained in:
@@ -7,23 +7,17 @@ import {
|
||||
} from './GetTotalDriversUseCase';
|
||||
import { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
|
||||
describe('GetTotalDriversUseCase', () => {
|
||||
let useCase: GetTotalDriversUseCase;
|
||||
let driverRepository: {
|
||||
findAll: Mock;
|
||||
};
|
||||
let output: UseCaseOutputPort<GetTotalDriversResult>;
|
||||
beforeEach(() => {
|
||||
driverRepository = {
|
||||
findAll: vi.fn(),
|
||||
};
|
||||
output = {
|
||||
present: vi.fn(),
|
||||
};
|
||||
|
||||
useCase = new GetTotalDriversUseCase(driverRepository as unknown as IDriverRepository, output);
|
||||
useCase = new GetTotalDriversUseCase(driverRepository as unknown as IDriverRepository);
|
||||
});
|
||||
|
||||
it('should return total number of drivers', async () => {
|
||||
@@ -36,8 +30,7 @@ describe('GetTotalDriversUseCase', () => {
|
||||
const result = await useCase.execute(input);
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(output.present).toHaveBeenCalledWith({ totalDrivers: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error on repository failure', async () => {
|
||||
const error = new Error('Repository error');
|
||||
|
||||
Reference in New Issue
Block a user