ControllerTests: Add connection to controller tests

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-04-11 22:06:41 +02:00
parent f7e483da81
commit f967b34018
4 changed files with 32 additions and 4 deletions

View file

@ -10,7 +10,11 @@ import { LoggerModule } from '../../../../logger/logger.module';
import { UsersModule } from '../../../../users/users.module';
import { HistoryModule } from '../../../../history/history.module';
import { NotesModule } from '../../../../notes/notes.module';
import { getRepositoryToken } from '@nestjs/typeorm';
import {
getConnectionToken,
getRepositoryToken,
TypeOrmModule,
} from '@nestjs/typeorm';
import { User } from '../../../../users/user.entity';
import { Note } from '../../../../notes/note.entity';
import { AuthToken } from '../../../../auth/auth-token.entity';
@ -41,8 +45,11 @@ describe('HistoryController', () => {
isGlobal: true,
load: [appConfigMock],
}),
TypeOrmModule.forRoot(),
],
})
.overrideProvider(getConnectionToken())
.useValue({})
.overrideProvider(getRepositoryToken(User))
.useValue({})
.overrideProvider(getRepositoryToken(Note))

View file

@ -7,7 +7,11 @@
import { Test, TestingModule } from '@nestjs/testing';
import { NotesController } from './notes.controller';
import { NotesService } from '../../../notes/notes.service';
import { getRepositoryToken } from '@nestjs/typeorm';
import {
getConnectionToken,
getRepositoryToken,
TypeOrmModule,
} from '@nestjs/typeorm';
import { Note } from '../../../notes/note.entity';
import { Tag } from '../../../notes/tag.entity';
import { RevisionsModule } from '../../../revisions/revisions.module';
@ -61,8 +65,11 @@ describe('NotesController', () => {
isGlobal: true,
load: [appConfigMock, mediaConfigMock],
}),
TypeOrmModule.forRoot(),
],
})
.overrideProvider(getConnectionToken())
.useValue({})
.overrideProvider(getRepositoryToken(Note))
.useValue({})
.overrideProvider(getRepositoryToken(Revision))

View file

@ -5,7 +5,11 @@
*/
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import {
getConnectionToken,
getRepositoryToken,
TypeOrmModule,
} from '@nestjs/typeorm';
import { HistoryModule } from '../../../history/history.module';
import { LoggerModule } from '../../../logger/logger.module';
import { AuthorColor } from '../../../notes/author-color.entity';
@ -45,8 +49,11 @@ describe('Me Controller', () => {
NotesModule,
LoggerModule,
MediaModule,
TypeOrmModule.forRoot(),
],
})
.overrideProvider(getConnectionToken())
.useValue({})
.overrideProvider(getRepositoryToken(User))
.useValue({})
.overrideProvider(getRepositoryToken(Note))

View file

@ -5,7 +5,11 @@
*/
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import {
getConnectionToken,
getRepositoryToken,
TypeOrmModule,
} from '@nestjs/typeorm';
import { LoggerModule } from '../../../logger/logger.module';
import { AuthorColor } from '../../../notes/author-color.entity';
import { Note } from '../../../notes/note.entity';
@ -61,8 +65,11 @@ describe('Notes Controller', () => {
isGlobal: true,
load: [appConfigMock, mediaConfigMock],
}),
TypeOrmModule.forRoot(),
],
})
.overrideProvider(getConnectionToken())
.useValue({})
.overrideProvider(getRepositoryToken(Note))
.useValue({})
.overrideProvider(getRepositoryToken(Revision))