mirror of
https://gitlab.com/mobicoop/v3/service/user.git
synced 2026-03-27 14:05:51 +00:00
prsima, grpc
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsersRepository } from '../../adapters/secondaries/users.repository';
|
||||
import { FindUserByUuidUseCase } from '../../domain/usecases/find-user-by-uuid.usecase';
|
||||
import { FindUserByUuidQuery } from '../../queries/find-user-by-uuid.query';
|
||||
|
||||
const mockUser = {
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'john.doe@email.com',
|
||||
};
|
||||
|
||||
const mockUserRepository = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
findOneByUuid: jest.fn().mockImplementation((query?: FindUserByUuidQuery) => {
|
||||
return Promise.resolve(mockUser);
|
||||
}),
|
||||
};
|
||||
|
||||
describe('FindUserByUuidUseCase', () => {
|
||||
let findUserByUuidUseCase: FindUserByUuidUseCase;
|
||||
|
||||
beforeAll(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [],
|
||||
providers: [
|
||||
{
|
||||
provide: UsersRepository,
|
||||
useValue: mockUserRepository,
|
||||
},
|
||||
|
||||
FindUserByUuidUseCase,
|
||||
],
|
||||
}).compile();
|
||||
|
||||
findUserByUuidUseCase = module.get<FindUserByUuidUseCase>(
|
||||
FindUserByUuidUseCase,
|
||||
);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(findUserByUuidUseCase).toBeDefined();
|
||||
});
|
||||
|
||||
describe('execute', () => {
|
||||
it('should return a user', async () => {
|
||||
const user = await findUserByUuidUseCase.execute(
|
||||
new FindUserByUuidQuery('bb281075-1b98-4456-89d6-c643d3044a91'),
|
||||
);
|
||||
|
||||
expect(user).toBe(mockUser);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user