Newer
Older
import { JwtModule } from '@nestjs/jwt';
import { getModelToken } from '@nestjs/mongoose';
import { PassportModule } from '@nestjs/passport';
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigurationModule } from '../configuration/configuration.module';
import { MailerModule } from '../mailer/mailer.module';
import { User } from '../users/user.schema';
import { UsersService } from '../users/users.service';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
describe('AuthController', () => {
let controller: AuthController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [
PassportModule,
MailerModule,
ConfigurationModule,
JwtModule.register({
secret: process.env.JWT_SECRET,
signOptions: { expiresIn: '86400s' }, // 24h validity
}),
],
providers: [
AuthService,
UsersService,
{
provide: getModelToken('User'),
useValue: User,
},
],