Skip to content
Snippets Groups Projects

feat: TU for admin mailer and posts

Merged Antonin COQUET requested to merge feat/TU-posts-and-admin into dev
3 files
+ 69
1
Compare changes
  • Side-by-side
  • Inline
Files
3
import { HttpModule } from '@nestjs/common';
import { HttpException, HttpModule, HttpStatus } from '@nestjs/common';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigurationModule } from '../configuration/configuration.module';
import { MailerService } from '../mailer/mailer.service';
import { CreateStructureDto } from '../structures/dto/create-structure.dto';
import { structureDto } from '../structures/dto/structure.dto';
import { Structure } from '../structures/schemas/structure.schema';
import { StructuresService } from '../structures/services/structures.service';
import { User } from '../users/schemas/user.schema';
import { UsersService } from '../users/users.service';
import { AdminController } from './admin.controller';
import { PendingStructureDto } from './dto/pending-structure.dto';
describe('AdminController', () => {
let controller: AdminController;
@@ -37,4 +40,24 @@ describe('AdminController', () => {
it('should be defined', () => {
expect(controller).toBeDefined();
});
it('should get pending attachments', async () => {
const result = [{name: "MJC Route de vienne", address: "14 chemin des platanes"}, {name: "Mairie Lyon 7eme", address: "21 boulevard martin"}];
jest.spyOn(controller, 'getPendingAttachments').mockImplementation(async (): Promise<any> => result);
expect(await controller.getPendingAttachments()).toBe(result);
});
it('should validate pending structure', async () => {
const result = [{name: "MJC Route de vienne", address: "14 chemin des platanes"}];
const structure: PendingStructureDto = {userEmail:"martin@mjc.fr", structureId: "1", structureName:"MJC Route de vienne"};
jest.spyOn(controller, 'validatePendingStructure').mockImplementation(async (): Promise<any> => result);
expect(await controller.validatePendingStructure(structure)).toBe(result);
});
it('should refuse pending structure', async () => {
const result = [{name: "MJC Route de vienne", address: "14 chemin des platanes"}, {name: "Mairie Lyon 7eme", address: "21 boulevard martin"}];
const structure: PendingStructureDto = {userEmail:"martin@mjc.fr", structureId: "1", structureName:"MJC Route de vienne"};
jest.spyOn(controller, 'refusePendingStructure').mockImplementation(async (): Promise<any> => result);
expect(await controller.refusePendingStructure(structure)).toBe(result);
});
});
Loading