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

View file

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

View file

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

View file

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