delete authentication service tests
This commit is contained in:
parent
39924d1257
commit
e123f190c6
|
@ -0,0 +1,54 @@
|
|||
import { AUTHENTICATION_REPOSITORY } from '@modules/authentication/authentication.di-tokens';
|
||||
import { DeleteAuthenticationCommand } from '@modules/authentication/core/application/commands/delete-authentication/delete-authentication.command';
|
||||
import { DeleteAuthenticationService } from '@modules/authentication/core/application/commands/delete-authentication/delete-authentication.service';
|
||||
import { DeleteAuthenticationRequestDto } from '@modules/authentication/interface/grpc-controllers/dtos/delete-authentication.request.dto';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
const deleteAuthenticationRequest: DeleteAuthenticationRequestDto = {
|
||||
userId: '165192d4-398a-4469-a16b-98c02cc6f531',
|
||||
};
|
||||
|
||||
const mockAuthenticationEntity = {
|
||||
delete: jest.fn(),
|
||||
};
|
||||
|
||||
const mockAuthenticationRepository = {
|
||||
findOneById: jest.fn().mockImplementation(() => mockAuthenticationEntity),
|
||||
delete: jest.fn().mockImplementationOnce(() => true),
|
||||
};
|
||||
|
||||
describe('Delete Authentication Service', () => {
|
||||
let deleteAuthenticationService: DeleteAuthenticationService;
|
||||
|
||||
beforeAll(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
{
|
||||
provide: AUTHENTICATION_REPOSITORY,
|
||||
useValue: mockAuthenticationRepository,
|
||||
},
|
||||
DeleteAuthenticationService,
|
||||
],
|
||||
}).compile();
|
||||
|
||||
deleteAuthenticationService = module.get<DeleteAuthenticationService>(
|
||||
DeleteAuthenticationService,
|
||||
);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(deleteAuthenticationService).toBeDefined();
|
||||
});
|
||||
|
||||
describe('execution', () => {
|
||||
const deleteAuthenticationCommand = new DeleteAuthenticationCommand(
|
||||
deleteAuthenticationRequest,
|
||||
);
|
||||
it('should delete an authentication', async () => {
|
||||
const result: boolean = await deleteAuthenticationService.execute(
|
||||
deleteAuthenticationCommand,
|
||||
);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue