Skip to content
Snippets Groups Projects
Commit dc5ff80d authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

test: improve test coverage

parent 4ae8ad94
No related branches found
No related tags found
4 merge requests!247V2.1.0,!242V2.0,!193test/improve test coverage,!127V2.0
Showing with 703 additions and 202 deletions
......@@ -2,14 +2,24 @@ import { Test, TestingModule } from '@nestjs/testing';
import { ContactController } from './contact.controller';
import { ContactService } from './contact.service';
import { MailerModule } from '../mailer/mailer.module';
import { ContactMessage } from './schemas/contact-message.schema';
describe('ContactController', () => {
let controller: ContactController;
const contactServiceMock = {
sendMessage: jest.fn(),
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [MailerModule],
providers: [ContactService],
providers: [
{
provide: ContactService,
useValue: contactServiceMock,
},
],
controllers: [ContactController],
}).compile();
......@@ -19,4 +29,11 @@ describe('ContactController', () => {
it('should be defined', () => {
expect(controller).toBeDefined();
});
it('should call sendMessage', async () => {
const spyer = jest.spyOn(contactServiceMock, 'sendMessage');
await controller.sendContactMessage({ contactMessage: new ContactMessage() });
expect(spyer).toBeCalledTimes(1);
expect(spyer).toBeCalledWith(new ContactMessage());
});
});
......@@ -10,6 +10,6 @@ export class ContactController {
@Post('message')
public async sendContactMessage(@Body() data: { contactMessage: ContactMessage }): Promise<any> {
await this.contactService.sendMessage(data.contactMessage);
return this.contactService.sendMessage(data.contactMessage);
}
}
import { HttpStatus } from '@nestjs/common';
import { ContactMessage } from './schemas/contact-message.schema';
import { Test, TestingModule } from '@nestjs/testing';
import { MailerModule } from '../mailer/mailer.module';
import { ContactService } from './contact.service';
import { MailerService } from '../mailer/mailer.service';
import { MailerMockService } from '../../test/mock/services/mailer.mock.service';
import { HttpModule } from '@nestjs/axios';
import { ConfigurationService } from '../configuration/configuration.service';
describe('ContactService', () => {
let service: ContactService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [MailerModule],
providers: [ContactService],
imports: [HttpModule, MailerModule],
providers: [ContactService, ConfigurationService, { provide: MailerService, useClass: MailerMockService }],
}).compile();
service = module.get<ContactService>(ContactService);
......@@ -17,4 +23,9 @@ describe('ContactService', () => {
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should send message with status OK', async () => {
const res = await service.sendMessage(new ContactMessage());
expect(res.data.status).toBe(HttpStatus.OK);
});
});
......@@ -7,10 +7,18 @@ import { Parameters } from './schemas/parameters.schema';
describe('ParametersController', () => {
let controller: ParametersController;
const parametersServiceMock = {
getParameters: jest.fn(),
setParameterLockdownInfoDisplay: jest.fn(),
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
ParametersService,
{
provide: ParametersService,
useValue: parametersServiceMock,
},
{
provide: getModelToken('Parameters'),
useValue: Parameters,
......@@ -26,18 +34,25 @@ describe('ParametersController', () => {
expect(controller).toBeDefined();
});
it('should get parameters', async () => {
const result = { lockdownInfoDisplay: false };
jest.spyOn(controller, 'getParameters').mockImplementation(async (): Promise<Parameters> => result);
expect(await controller.getParameters()).toBe(result);
it('should call getParameters', async () => {
const spyer = jest.spyOn(parametersServiceMock, 'getParameters');
await controller.getParameters();
expect(spyer).toBeCalledTimes(1);
});
it('should set lockdownInfoDisplay', async () => {
const result = { lockdownInfoDisplay: false };
jest
.spyOn(controller, 'setParameterLockdownInfoDisplay')
.mockImplementation(async (): Promise<Parameters> => result);
const lockdownInfoDisplayValue = { lockdownInfoDisplay: false };
expect(await controller.setParameterLockdownInfoDisplay(lockdownInfoDisplayValue)).toBe(result);
describe('setParameterLockdownInfoDisplay', () => {
const spyer = jest.spyOn(parametersServiceMock, 'setParameterLockdownInfoDisplay');
afterEach(() => spyer.mockClear());
it('should call setParameterLockdownInfoDisplay(false) ', async () => {
await controller.setParameterLockdownInfoDisplay({ lockdownInfoDisplay: false });
expect(spyer).toBeCalledTimes(1);
expect(spyer).toBeCalledWith(false);
});
it('should call setParameterLockdownInfoDisplay(true)', async () => {
await controller.setParameterLockdownInfoDisplay({ lockdownInfoDisplay: true });
expect(spyer).toBeCalledTimes(1);
expect(spyer).toBeCalledWith(true);
});
});
});
import { HttpStatus } from '@nestjs/common';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { mockParametersModel } from '../../test/mock/services/parameters.mock.service';
import { IParameters } from './interface/parameters.interface';
import { ParametersService } from './parameters.service';
import { Parameters } from './schemas/parameters.schema';
describe('ParametersService', () => {
let service: ParametersService;
const parametersModelMock = {
findOne: jest.fn(),
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
ParametersService,
{
provide: getModelToken(Parameters.name),
useValue: mockParametersModel,
useValue: parametersModelMock,
},
],
}).compile();
service = module.get<ParametersService>(ParametersService);
});
afterEach(() => {
jest.clearAllMocks();
});
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should get parameters', async () => {
const result: IParameters = { lockdownInfoDisplay: false } as IParameters;
jest.spyOn(service, 'getParameters').mockImplementation(async (): Promise<Parameters> => result);
expect(await service.getParameters()).toBe(result);
describe('getParameters', () => {
it('should get parameters', async () => {
const spyer = jest.spyOn(parametersModelMock, 'findOne');
parametersModelMock.findOne.mockResolvedValueOnce({ lockdownInfoDisplay: false });
const result = await service.getParameters();
expect(spyer).toBeCalledTimes(1);
expect(result).toEqual({ lockdownInfoDisplay: false });
});
it('should throw error because parameters was not found', async () => {
const spyer = jest.spyOn(parametersModelMock, 'findOne');
parametersModelMock.findOne.mockResolvedValueOnce(null);
try {
await service.getParameters();
expect(true).toBe(false);
} catch (error) {
expect(error.message).toBe('Parameters not found');
expect(error.status).toBe(HttpStatus.NOT_FOUND);
}
expect(spyer).toBeCalledTimes(1);
});
});
it('should set Parameter LockdownInfoDisplay', async () => {
const result: IParameters = { lockdownInfoDisplay: false } as IParameters;
jest.spyOn(service, 'setParameterLockdownInfoDisplay').mockImplementation(async (): Promise<Parameters> => result);
expect(await service.setParameterLockdownInfoDisplay(false)).toBe(result);
describe('setParameters', () => {
it('should set parameters', async () => {
const spyer = jest.spyOn(parametersModelMock, 'findOne');
parametersModelMock.findOne.mockResolvedValueOnce({ lockdownInfoDisplay: false, save: jest.fn() });
const result = await service.setParameterLockdownInfoDisplay(true);
expect(spyer).toBeCalledTimes(1);
expect(result.lockdownInfoDisplay).toEqual(true);
});
it('should throw error because parameters was not found', async () => {
const spyer = jest.spyOn(parametersModelMock, 'findOne');
parametersModelMock.findOne.mockResolvedValueOnce(null);
try {
await service.setParameterLockdownInfoDisplay(true);
expect(true).toBe(false);
} catch (error) {
expect(error.message).toBe('Parameters not found');
expect(error.status).toBe(HttpStatus.NOT_FOUND);
}
expect(spyer).toBeCalledTimes(1);
});
});
});
......@@ -84,11 +84,10 @@ export class TempUserService {
}
public async getStructureTempUsers(structureId: string): Promise<ITempUser[]> {
const tempUsers = await this.tempUserModel
return this.tempUserModel
.find({ pendingStructuresLink: Types.ObjectId(structureId) })
.select('email updatedAt')
.exec();
return tempUsers;
}
public async removeFromStructureLinked(userEmail: string, idStructure: string): Promise<Types.ObjectId[]> {
......
import { HttpModule } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Types } from 'mongoose';
......@@ -14,13 +15,20 @@ import { StructuresSearchService } from '../../structures/services/structures-se
import { StructuresService } from '../../structures/services/structures.service';
import { TempUser } from '../../temp-user/temp-user.schema';
import { TempUserService } from '../../temp-user/temp-user.service';
import { EmailChangeDto } from '../dto/change-email.dto';
import { PasswordChangeDto } from '../dto/change-password.dto';
import { DescriptionDto } from '../dto/description.dto';
import { ProfileDto } from '../dto/profile.dto';
import { UpdateDetailsDto } from '../dto/update-details.dto';
import { User } from '../schemas/user.schema';
import { EmployerService } from '../services/employer.service';
import { JobsService } from '../services/jobs.service';
import { UsersService } from '../services/users.service';
import { PasswordResetApplyDto } from './../dto/reset-password-apply.dto';
import { PasswordResetDto } from './../dto/reset-password.dto';
import { UsersController } from './users.controller';
import { usersMockData } from '../../../test/mock/data/users.mock.data';
import { CreateUserDto } from '../dto/create-user.dto';
describe('UsersController', () => {
let controller: UsersController;
......@@ -34,9 +42,34 @@ describe('UsersController', () => {
};
const userServiceMock = {
updateUserProfile: jest.fn(),
changeUserEmail: jest.fn(),
changeUserPassword: jest.fn(),
create: jest.fn(),
deleteOne: jest.fn(),
findById: jest.fn(),
findOne: jest.fn(),
isStructureClaimed: jest.fn(),
sendResetPasswordEmail: jest.fn(),
updateDescription: jest.fn(),
updateStructureLinkedClaim: jest.fn(),
updateUserDetails: jest.fn(),
updateUserProfile: jest.fn(),
validatePasswordResetToken: jest.fn(),
validateUser: jest.fn(),
verifyAndUpdateUserEmail: jest.fn(),
verifyUserExist: jest.fn(),
};
const structureServiceMock = {
deleteOne: jest.fn(),
findOne: jest.fn(),
getAllDataConsentPendingStructures: jest.fn(),
sendAdminStructureNotification: jest.fn(),
};
const tempUserServiceMock = {
delete: jest.fn(),
findOne: jest.fn(),
};
beforeEach(async () => {
......@@ -44,15 +77,21 @@ describe('UsersController', () => {
imports: [ConfigurationModule, HttpModule, SearchModule],
providers: [
UsersService,
StructuresService,
StructuresSearchService,
MailerService,
TempUserService,
ParametersService,
{
provide: StructuresService,
useValue: structureServiceMock,
},
{
provide: UsersService,
useValue: userServiceMock,
},
{
provide: TempUserService,
useValue: tempUserServiceMock,
},
{
provide: EmployerService,
useValue: employerServiceMock,
......@@ -84,6 +123,9 @@ describe('UsersController', () => {
],
controllers: [UsersController],
}).compile();
afterEach(() => {
jest.clearAllMocks();
});
controller = module.get<UsersController>(UsersController);
});
......@@ -92,6 +134,14 @@ describe('UsersController', () => {
expect(controller).toBeDefined();
});
describe('getProfile', () => {
it('should return user', () => {
const user = { _id: '36', email: 'a@a.com' };
const result = controller.getProfile({ user: user });
expect(result).toEqual(user);
});
});
describe('setProfile', () => {
it('should return employer does not exist', async () => {
const profile: ProfileDto = {
......@@ -163,7 +213,6 @@ describe('UsersController', () => {
job: Types.ObjectId('6231aefe76598527c8d0b5be'),
});
const reply = await controller.setProfile({ user: { _id: '36', email: 'a@a.com' } }, profile);
console.log(reply);
expect(reply).toBeTruthy();
});
});
......@@ -196,8 +245,198 @@ describe('UsersController', () => {
job: Types.ObjectId('6231aefe76598527c8d0b5be'),
});
const reply = await controller.updateDetails({ user: { _id: '36', email: 'a@a.com' } }, newDetails);
console.log(reply);
expect(reply).toBeTruthy();
});
});
describe('create', () => {
it('should create user without structure', async () => {
const userCreateSpyer = jest.spyOn(userServiceMock, 'create');
const structureFindOneSpyer = jest.spyOn(structureServiceMock, 'findOne');
const updateStructureLinkedClaimSpyer = jest.spyOn(userServiceMock, 'updateStructureLinkedClaim');
const sendAdminStructureNotificationSpyer = jest.spyOn(structureServiceMock, 'sendAdminStructureNotification');
const tempUserFindOneSpyer = jest.spyOn(tempUserServiceMock, 'findOne');
const tempUserDeleteSpyer = jest.spyOn(tempUserServiceMock, 'delete');
const createUserDto = new CreateUserDto();
createUserDto.pendingStructuresLink = [];
userServiceMock.create.mockResolvedValueOnce(usersMockData[0]);
const result = await controller.create(createUserDto);
expect(userCreateSpyer).toBeCalledTimes(1);
expect(structureFindOneSpyer).toBeCalledTimes(0);
expect(updateStructureLinkedClaimSpyer).toBeCalledTimes(0);
expect(sendAdminStructureNotificationSpyer).toBeCalledTimes(0);
expect(tempUserFindOneSpyer).toBeCalledTimes(1);
expect(tempUserDeleteSpyer).toBeCalledTimes(0);
expect(result).toEqual(usersMockData[0]);
});
it('should create user with structure', async () => {
const userCreateSpyer = jest.spyOn(userServiceMock, 'create');
const structureFindOneSpyer = jest.spyOn(structureServiceMock, 'findOne');
const updateStructureLinkedClaimSpyer = jest.spyOn(userServiceMock, 'updateStructureLinkedClaim');
const sendAdminStructureNotificationSpyer = jest.spyOn(structureServiceMock, 'sendAdminStructureNotification');
const tempUserFindOneSpyer = jest.spyOn(tempUserServiceMock, 'findOne');
const tempUserDeleteSpyer = jest.spyOn(tempUserServiceMock, 'delete');
const createUserDto = new CreateUserDto();
createUserDto.pendingStructuresLink = ['6093ba0e2ab5775cfc01fffe'];
userServiceMock.create.mockResolvedValueOnce(usersMockData[0]);
const result = await controller.create(createUserDto);
expect(userCreateSpyer).toBeCalledTimes(1);
expect(structureFindOneSpyer).toBeCalledTimes(1);
expect(updateStructureLinkedClaimSpyer).toBeCalledTimes(1);
expect(sendAdminStructureNotificationSpyer).toBeCalledTimes(1);
expect(tempUserFindOneSpyer).toBeCalledTimes(1);
expect(tempUserDeleteSpyer).toBeCalledTimes(0);
expect(result).toEqual(usersMockData[0]);
});
it('should create user with temp user', async () => {
const userCreateSpyer = jest.spyOn(userServiceMock, 'create');
const structureFindOneSpyer = jest.spyOn(structureServiceMock, 'findOne');
const updateStructureLinkedClaimSpyer = jest.spyOn(userServiceMock, 'updateStructureLinkedClaim');
const sendAdminStructureNotificationSpyer = jest.spyOn(structureServiceMock, 'sendAdminStructureNotification');
const tempUserFindOneSpyer = jest.spyOn(tempUserServiceMock, 'findOne');
const tempUserDeleteSpyer = jest.spyOn(tempUserServiceMock, 'delete');
const createUserDto = new CreateUserDto();
createUserDto.pendingStructuresLink = [];
userServiceMock.create.mockResolvedValueOnce(usersMockData[0]);
tempUserServiceMock.findOne.mockResolvedValueOnce({ email: 'test@test.com', pendingStructuresLink: [] });
const result = await controller.create(createUserDto);
expect(userCreateSpyer).toBeCalledTimes(1);
expect(structureFindOneSpyer).toBeCalledTimes(0);
expect(updateStructureLinkedClaimSpyer).toBeCalledTimes(0);
expect(sendAdminStructureNotificationSpyer).toBeCalledTimes(0);
expect(tempUserFindOneSpyer).toBeCalledTimes(1);
expect(tempUserDeleteSpyer).toBeCalledTimes(1);
expect(result).toEqual(usersMockData[0]);
});
});
describe('validateUser', () => {
it('should call validateUser', async () => {
const spyer = jest.spyOn(userServiceMock, 'validateUser');
await controller.validateUser({ id: 1 }, 'token');
expect(spyer).toBeCalledTimes(1);
});
});
describe('changePassword', () => {
it('should call changeUserPassword', async () => {
const spyer = jest.spyOn(userServiceMock, 'changeUserPassword');
await controller.changePassword({ user: { _id: '36', email: 'a@a.com' } }, new PasswordChangeDto());
expect(spyer).toBeCalledTimes(1);
});
});
describe('changeEmail', () => {
it('should call changeUserEmail', async () => {
const spyer = jest.spyOn(userServiceMock, 'changeUserEmail');
await controller.changeEmail(new EmailChangeDto());
expect(spyer).toBeCalledTimes(1);
});
});
describe('verifyAndUpdateEmail', () => {
it('should call verifyAndUpdateUserEmail', async () => {
const spyer = jest.spyOn(userServiceMock, 'verifyAndUpdateUserEmail');
await controller.verifyAndUpdateEmail('token');
expect(spyer).toBeCalledTimes(1);
});
});
describe('resetPassword', () => {
it('should call sendResetPasswordEmail', async () => {
const spyer = jest.spyOn(userServiceMock, 'sendResetPasswordEmail');
await controller.resetPassword(new PasswordResetDto());
expect(spyer).toBeCalledTimes(1);
});
});
describe('resetPasswordApply', () => {
it('should call validatePasswordResetToken', async () => {
const spyer = jest.spyOn(userServiceMock, 'validatePasswordResetToken');
await controller.resetPasswordApply(new PasswordResetApplyDto());
expect(spyer).toBeCalledTimes(1);
});
});
describe('verifyUserExist', () => {
it('should call verifyUserExist', async () => {
const spyer = jest.spyOn(userServiceMock, 'verifyUserExist');
await controller.verifyUserExist({ user: { _id: '36', email: 'a@a.com' } }, { newMail: 'test@test.com' });
expect(spyer).toBeCalledTimes(1);
});
});
describe('delete', () => {
it('should not call isStructureClaimed if no structures are linked', async () => {
const deleteOneSpyer = jest.spyOn(userServiceMock, 'deleteOne');
const isStructureClaimedSpyer = jest.spyOn(userServiceMock, 'isStructureClaimed');
const userWithoutStructure = usersMockData[2];
userServiceMock.deleteOne.mockResolvedValueOnce(userWithoutStructure);
await controller.delete({ user: { _id: '36', email: 'a@a.com' } });
expect(deleteOneSpyer).toBeCalledTimes(1);
expect(isStructureClaimedSpyer).toBeCalledTimes(0);
});
it('should call isStructureClaimed for each structure linked', async () => {
const userDeleteOneSpyer = jest.spyOn(userServiceMock, 'deleteOne');
const isStructureClaimedSpyer = jest.spyOn(userServiceMock, 'isStructureClaimed');
const structureDeleteOneSpyer = jest.spyOn(structureServiceMock, 'deleteOne');
const userWithThreeStructures = usersMockData[3];
userServiceMock.deleteOne.mockResolvedValueOnce(userWithThreeStructures);
userServiceMock.isStructureClaimed.mockResolvedValue(null);
userServiceMock.isStructureClaimed.mockResolvedValueOnce(userWithThreeStructures);
await controller.delete({ user: { _id: '36', email: 'a@a.com' } });
expect(userDeleteOneSpyer).toBeCalledTimes(1);
expect(isStructureClaimedSpyer).toBeCalledTimes(3);
expect(structureDeleteOneSpyer).toBeCalledTimes(2);
});
});
describe('dataConsentValidation', () => {
it('should call getAllDataConsentPendingStructures', async () => {
const spyer = jest.spyOn(structureServiceMock, 'getAllDataConsentPendingStructures');
await controller.dataConsentValidation({ user: { _id: '36', email: 'a@a.com' } });
expect(spyer).toBeCalledTimes(1);
});
});
describe('get user', () => {
it('should return user', async () => {
const spyer = jest.spyOn(userServiceMock, 'findById');
userServiceMock.findById.mockResolvedValueOnce({ _id: '36', email: 'a@a.com' });
const result = await controller.getUser(1);
expect(result).toEqual({ _id: '36', email: 'a@a.com' });
expect(spyer).toBeCalledTimes(1);
});
it('should throw error if no user found', async () => {
const spyer = jest.spyOn(userServiceMock, 'findById');
userServiceMock.findById.mockResolvedValueOnce(null);
try {
await controller.getUser(1);
expect(true).toBe(false);
} catch (error) {
expect(error.message).toBe('User does not exist');
expect(error.status).toBe(HttpStatus.NOT_FOUND);
}
expect(spyer).toBeCalledTimes(1);
});
});
describe('update description', () => {
it('should call updateDescription', async () => {
const spyer = jest.spyOn(userServiceMock, 'updateDescription');
await controller.updateDescription({ user: { _id: '36', email: 'a@a.com' } }, new DescriptionDto());
expect(spyer).toBeCalledTimes(1);
});
});
});
......@@ -94,6 +94,7 @@ export class UsersController {
@Post()
@ApiResponse({ status: 201, description: 'User created' })
public async create(@Body() createUserDto: CreateUserDto) {
this.logger.debug('create');
// remove structureId for creation and add structure after
let structureId = null;
if (createUserDto.pendingStructuresLink.length > 0) {
......@@ -144,7 +145,7 @@ export class UsersController {
@Post('change-email')
@ApiResponse({ status: 201, description: 'Email confirmation send' })
@ApiResponse({ status: 401, description: 'Invalid Email' })
public async changeEmail(@Request() _req, @Body() emailChangeDto: EmailChangeDto) {
public async changeEmail(@Body() emailChangeDto: EmailChangeDto) {
return this.usersService.changeUserEmail(emailChangeDto);
}
......@@ -152,7 +153,7 @@ export class UsersController {
@Post('verify-change-email')
@ApiResponse({ status: 201, description: 'Email changed' })
@ApiResponse({ status: 401, description: 'Invalid Token' })
public async verifyAndUpdateEmail(@Request() _req, @Query('token') token: string) {
public async verifyAndUpdateEmail(@Query('token') token: string) {
return this.usersService.verifyAndUpdateUserEmail(token);
}
......
......@@ -27,7 +27,7 @@ export class CreateUserDto {
@IsArray()
@IsOptional()
pendingStructuresLink?: Array<number>;
pendingStructuresLink?: Array<string>;
@IsArray()
@IsOptional()
......
This diff is collapsed.
......@@ -41,6 +41,7 @@ export class UsersService {
throw new HttpException('User already exists', HttpStatus.BAD_REQUEST);
}
if (!this.isStrongPassword(createUserDto.password)) {
console.log('weak pass');
throw new HttpException(
'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer',
HttpStatus.UNPROCESSABLE_ENTITY
......@@ -57,7 +58,7 @@ export class UsersService {
// Send verification email
createUser = await this.verifyUserMail(createUser);
createUser.save();
await createUser.save();
this.userRegistrySearchService.indexUserRegistry(createUser);
return this.findOne(createUserDto.email);
}
......@@ -71,7 +72,7 @@ export class UsersService {
* - The string must be eight characters or longer
* @param password string
*/
private isStrongPassword(password: string): boolean {
public isStrongPassword(password: string): boolean {
const strongRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[*.! @#$%^&(){}\[\]:;<>,?\/\\~_+\-=|])(?=.{8,})/; //NOSONAR
return strongRegex.test(password);
}
......
......@@ -55,6 +55,48 @@ export const usersMockData: IUser[] = [
__v: 1,
save: jest.fn(),
} as any,
{
structureOutdatedMailSent: [],
pendingStructuresLink: ['6001a48e16b08100062e4180', '6093ba0e2ab5775cfc01fffe'],
structuresLink: [],
newEmail: null,
changeEmailToken: null,
role: 0,
resetPasswordToken: null,
validationToken:
'b2b6caca1d38ca26d203b5f12b0d925df2928fab8ee7ccf9bbe78802ffa625f5abce825783bc62d0b11be5a90132cf5045a9a7776f01694c63b60bf64b0f680f',
emailVerified: false,
_id: '6036721022462b001334c4bb',
email: 'a@a.com',
name: 'Xavier',
surname: 'NIEL',
phone: '06 11 11 11 11',
password: '$2a$12$vLQjJ9zAWyUwiXLeQDa6w.XzrlgPBhw.2GWrjog/yuEjIaZnQwmZu',
personalOffers: [],
__v: 1,
save: jest.fn(),
} as any,
{
structureOutdatedMailSent: [],
pendingStructuresLink: ['6001a48e16b08100062e4180', '6093ba0e2ab5775cfc01fffe'],
structuresLink: ['6093ba0e2ab5775cfc01fffe', '6093ba0e2ab5775cfc01ffff', '6093ba0e2ab5775cfc020000'],
newEmail: null,
changeEmailToken: null,
role: 0,
resetPasswordToken: null,
validationToken:
'b2b6caca1d38ca26d203b5f12b0d925df2928fab8ee7ccf9bbe78802ffa625f5abce825783bc62d0b11be5a90132cf5045a9a7776f01694c63b60bf64b0f680f',
emailVerified: false,
_id: '6036721022462b001334c4bb',
email: 'a@a.com',
name: 'Xavier',
surname: 'NIEL',
phone: '06 11 11 11 11',
password: '$2a$12$vLQjJ9zAWyUwiXLeQDa6w.XzrlgPBhw.2GWrjog/yuEjIaZnQwmZu',
personalOffers: [],
__v: 1,
save: jest.fn(),
} as any,
] as IUser[];
export const userDetails: IUser[] = [
......
import { AxiosResponse } from 'axios';
import { MailerService } from '../../../src/mailer/mailer.service';
export class MailerMockService extends MailerService {
public async send(_to: string | { email: string }[], _subject: string, _html: string): Promise<AxiosResponse<any>> {
const axiosResult: AxiosResponse = {
data: { status: 200 },
status: 200,
statusText: 'OK',
headers: {},
config: {},
};
return Promise.resolve(axiosResult);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment