From f967b34018a4bc9b2e4331375b651faca062588d Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sun, 11 Apr 2021 22:06:41 +0200 Subject: [PATCH] ControllerTests: Add connection to controller tests Signed-off-by: Philip Molares --- src/api/private/me/history/history.controller.spec.ts | 9 ++++++++- src/api/private/notes/notes.controller.spec.ts | 9 ++++++++- src/api/public/me/me.controller.spec.ts | 9 ++++++++- src/api/public/notes/notes.controller.spec.ts | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/api/private/me/history/history.controller.spec.ts b/src/api/private/me/history/history.controller.spec.ts index caf73a292..2b5da6db2 100644 --- a/src/api/private/me/history/history.controller.spec.ts +++ b/src/api/private/me/history/history.controller.spec.ts @@ -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)) diff --git a/src/api/private/notes/notes.controller.spec.ts b/src/api/private/notes/notes.controller.spec.ts index d42903ca7..c1a3f8ad4 100644 --- a/src/api/private/notes/notes.controller.spec.ts +++ b/src/api/private/notes/notes.controller.spec.ts @@ -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)) diff --git a/src/api/public/me/me.controller.spec.ts b/src/api/public/me/me.controller.spec.ts index 0274ee1d8..bf61c10a6 100644 --- a/src/api/public/me/me.controller.spec.ts +++ b/src/api/public/me/me.controller.spec.ts @@ -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)) diff --git a/src/api/public/notes/notes.controller.spec.ts b/src/api/public/notes/notes.controller.spec.ts index 789b5220a..867e36d9e 100644 --- a/src/api/public/notes/notes.controller.spec.ts +++ b/src/api/public/notes/notes.controller.spec.ts @@ -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))