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 committed by David Mehren
parent 0933b88ff5
commit 258a38f8c0
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
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))