Unit tests
This commit is contained in:
39
api/src/modules/auth/auth.service.specc.ts
Normal file
39
api/src/modules/auth/auth.service.specc.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthService } from './auth.service';
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
import { UserRepository } from 'src/model/repositories';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { MockUserRepository } from '../../../mocks/repositories/user.repository.mock';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [AuthService,
|
||||
{provide: UserRepository, useClass: MockUserRepository},
|
||||
{provide: HttpService, useClass: MockHttpService},
|
||||
ConfigService,
|
||||
JwtService
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<AuthService>(AuthService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
it('should store a user on creation', async () => {
|
||||
// const user = await service.register({externalId: '123', username: 'sc'});
|
||||
// expect(service['userRepo'].createUser).toHaveBeenCalled();
|
||||
// expect(user.external.externalId).toEqual('123');
|
||||
// expect(user.username).toEqual('sc');
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
class MockHttpService {}
|
||||
Reference in New Issue
Block a user