Add various missing imports and provider ovverides in unit tests

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-10-17 20:21:22 +02:00
parent 5a07abfd43
commit d41b68b41a
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 81 additions and 6 deletions

View file

@ -1,5 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { LoggerModule } from '../logger/logger.module';
import { User } from './user.entity';
import { UsersService } from './users.service';
describe('UsersService', () => {
@ -7,9 +9,18 @@ describe('UsersService', () => {
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UsersService],
providers: [
UsersService,
{
provide: getRepositoryToken(User),
useValue: {},
},
],
imports: [LoggerModule],
}).compile();
})
.overrideProvider(getRepositoryToken(User))
.useValue({})
.compile();
service = module.get<UsersService>(UsersService);
});