Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Commits on Source (25)
Showing
with 16198 additions and 11779 deletions
module.exports = { module.exports = {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {
project: 'tsconfig.json', project: true,
sourceType: 'module', sourceType: 'module',
}, },
plugins: ['@typescript-eslint/eslint-plugin'], plugins: ['@typescript-eslint/eslint-plugin'],
......
...@@ -74,7 +74,7 @@ deploy_dev: ...@@ -74,7 +74,7 @@ deploy_dev:
test: test:
stage: test stage: test
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:14.15.4 image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:18.17.0
services: services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/elasticsearch:7.16.2 - name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/elasticsearch:7.16.2
alias: elasticsearch alias: elasticsearch
...@@ -120,7 +120,7 @@ sonarqube: ...@@ -120,7 +120,7 @@ sonarqube:
-Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.projectKey=${SONAR_PROJECT_KEY}
-Dsonar.login=${SONAR_TOKEN} -Dsonar.login=${SONAR_TOKEN}
-Dsonar.cpd.exclusions=test/**,scripts/**,src/**/*.spec.ts* -Dsonar.cpd.exclusions=test/**,scripts/**,src/**/*.spec.ts*
-Dsonar.exclusions=test/**,scripts/**,src/**/*.spec.ts*,src/migrations/scripts/** -Dsonar.exclusions=test/**,scripts/**,src/**/*.spec.ts*,src/migrations/scripts/**
-Dsonar.qualitygate.wait=true -Dsonar.qualitygate.wait=true
sonarqube-mr: sonarqube-mr:
......
v14 18
...@@ -38,17 +38,21 @@ ...@@ -38,17 +38,21 @@
}, },
"editor.formatOnSave": true, "editor.formatOnSave": true,
"typescript.preferences.importModuleSpecifier": "relative", "typescript.preferences.importModuleSpecifier": "relative",
"gitlens.remotes": [{ "type": "GitLab", "domain": "forge.grandlyon.com", "name": "Forge" }],
"cSpell.words": [ "cSpell.words": [
"aidant", "aidant",
"aidants", "aidants",
"aptic", "aptic",
"cnfs", "cnfs",
"courriel", "courriel",
"cpam",
"espace", "espace",
"grandlyon", "grandlyon",
"nestjs", "nestjs",
"orientator", "orientator",
"permanences", "permanences",
"photonban" "photonban",
"spyer",
"Unvalidated"
] ]
} }
...@@ -2,6 +2,25 @@ ...@@ -2,6 +2,25 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.4.2](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.4.1...v2.4.2) (2023-10-05)
### Features
* **online-demarch:** remove cpam ([556658d](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/556658dd0b5de94c1359765ea1bbd89cfa527089))
* remove pix label ([b306108](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/b306108ecec74efbc23d6c1dfcff798c988e381b))
* **structureTypes:** new structure types list ([e7e1ae8](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/e7e1ae80276c77d3f9d9803b7d261f55f458dcb3))
### Bug Fixes
* **export:** exported structures now contain a unique id field ([8196f90](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/8196f9088362aaec553aec5642c6c6cf0d02506a))
* **import:** handles osm "off" hours ([a804eda](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/a804eda7d1ea97d2db6046f174a9cea0d3d1e23b))
* **indicator:** handle prescripteur profile when storing orientation event ([50d1821](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/50d1821d190a344f1f00c50f499639b0274b2937))
* **map:** avoid error 500 if no structure position ([8dfdf08](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/8dfdf08c2b517b939a14cee76a7463f4537fc3c9))
* **orientation:** only use personal offers for structure rdv ([0d6c66d](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/0d6c66d36fdafa1b35ebf2bceec8f60666cf1364))
* **rdv:** filter offers of users with rdv ([4c29d54](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/4c29d540f06ff52ddda7b52dc55e72d4681fb708))
### [2.4.1](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.4.0...v2.4.1) (2023-08-25) ### [2.4.1](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.4.0...v2.4.1) (2023-08-25)
......
FROM node:14.20-slim FROM node:18-bullseye
# Create app directory # Create app directory
WORKDIR /app WORKDIR /app
......
import type { Config } from 'jest';
const config: Config = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '/src/.*\\.(test|spec).(ts|tsx|js)$',
collectCoverageFrom: ['src/**/*.{js,jsx,tsx,ts}', '!**/node_modules/**', '!**/vendor/**'],
reporters: ['default', 'jest-junit'],
};
export default config;
{
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/src/.*\\.(test|spec).(ts|tsx|js)$",
"collectCoverageFrom": ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],
"coverageReporters": ["json", "lcov"],
"reporters": ["default", "jest-junit"]
}
This diff is collapsed.
{ {
"name": "ram_server", "name": "ram_server",
"private": true, "private": true,
"version": "2.4.1", "version": "2.4.2",
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
"release": "standard-version", "release": "standard-version",
"start:debug": "nodemon --config nodemon-debug.json", "start:debug": "nodemon --config nodemon-debug.json",
"start:dev": "nodemon", "start:dev": "nodemon",
"test": "jest --runInBand --config ./jest.json",
"start:prod": "npm run migrate:up && node dist/src/main", "start:prod": "npm run migrate:up && node dist/src/main",
"test:cov": "jest --config ./jest.json --coverage --ci --reporters=default --reporters=jest-junit", "test": "jest --runInBand --config ./jest.config.ts",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:cov": "jest --config ./jest.config.ts --coverage --ci --reporters=default --reporters=jest-junit",
"test:debug": "node --config ./jest.config.ts --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json", "test:e2e": "jest --config ./test/jest-e2e.json",
"test:watch": "jest --config ./jest.json --watch --coverage" "test:watch": "jest --config ./jest.config.ts --watch --coverage"
}, },
"dependencies": { "dependencies": {
"@elastic/elasticsearch": "~8.5.0", "@elastic/elasticsearch": "~8.5.0",
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
"@nestjs/testing": "^9.0.11", "@nestjs/testing": "^9.0.11",
"@types/express": "^4.17.8", "@types/express": "^4.17.8",
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/node": "^14.14.6", "@types/node": "^18.0.0",
"@types/passport-local": "^1.0.33", "@types/passport-local": "^1.0.33",
"@types/supertest": "^2.0.10", "@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^5.37", "@typescript-eslint/eslint-plugin": "^5.37",
...@@ -91,22 +91,5 @@ ...@@ -91,22 +91,5 @@
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"typescript": "^4.2.4" "typescript": "^4.2.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
} }
} }
...@@ -18,6 +18,8 @@ module.exports = { ...@@ -18,6 +18,8 @@ module.exports = {
email: 'admin@admin.com', email: 'admin@admin.com',
structureOutdatedMailSent: [], structureOutdatedMailSent: [],
unattachedSince: Date.now(), unattachedSince: Date.now(),
job: null,
employer: null,
}, },
{ {
structureOutdatedMailSent: [], structureOutdatedMailSent: [],
......
...@@ -2,6 +2,7 @@ import { HttpModule } from '@nestjs/axios'; ...@@ -2,6 +2,7 @@ import { HttpModule } from '@nestjs/axios';
import { getModelToken } from '@nestjs/mongoose'; import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { Types } from 'mongoose'; import { Types } from 'mongoose';
import { structuresDocumentDataMock } from '../../test/mock/data/structures.mock.data';
import { mockJwtAuthGuard } from '../../test/mock/guards/jwt-auth.mock.guard'; import { mockJwtAuthGuard } from '../../test/mock/guards/jwt-auth.mock.guard';
import { mockRoleGuard } from '../../test/mock/guards/role.mock.guard'; import { mockRoleGuard } from '../../test/mock/guards/role.mock.guard';
import { NewsletterServiceMock } from '../../test/mock/services/newsletter.mock.service'; import { NewsletterServiceMock } from '../../test/mock/services/newsletter.mock.service';
...@@ -9,6 +10,8 @@ import { StructuresServiceMock } from '../../test/mock/services/structures.mock. ...@@ -9,6 +10,8 @@ import { StructuresServiceMock } from '../../test/mock/services/structures.mock.
import { UsersServiceMock } from '../../test/mock/services/user.mock.service'; import { UsersServiceMock } from '../../test/mock/services/user.mock.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { ConfigurationModule } from '../configuration/configuration.module'; import { ConfigurationModule } from '../configuration/configuration.module';
import { EspaceCoopCNFS } from '../espaceCoop/schemas/espaceCoopCNFS.schema';
import { EspaceCoopService } from '../espaceCoop/services/espaceCoop.service';
import { MailerService } from '../mailer/mailer.service'; import { MailerService } from '../mailer/mailer.service';
import { NewsletterSubscription } from '../newsletter/newsletter-subscription.schema'; import { NewsletterSubscription } from '../newsletter/newsletter-subscription.schema';
import { NewsletterService } from '../newsletter/newsletter.service'; import { NewsletterService } from '../newsletter/newsletter.service';
...@@ -25,11 +28,9 @@ import { UsersService } from '../users/services/users.service'; ...@@ -25,11 +28,9 @@ import { UsersService } from '../users/services/users.service';
import { AdminController } from './admin.controller'; import { AdminController } from './admin.controller';
import { AdminService } from './admin.service'; import { AdminService } from './admin.service';
import { PendingStructureDto } from './dto/pending-structure.dto'; import { PendingStructureDto } from './dto/pending-structure.dto';
import { EspaceCoopService } from '../espaceCoop/services/espaceCoop.service';
import { EspaceCoopCNFS } from '../espaceCoop/schemas/espaceCoopCNFS.schema';
describe('AdminController', () => { describe('AdminController', () => {
let controller: AdminController; let adminController: AdminController;
let userService: UsersService; let userService: UsersService;
const mockEmployerSearchService = { const mockEmployerSearchService = {
...@@ -65,6 +66,20 @@ describe('AdminController', () => { ...@@ -65,6 +66,20 @@ describe('AdminController', () => {
mergeJob: jest.fn(), mergeJob: jest.fn(),
deleteInvalidJob: jest.fn(), deleteInvalidJob: jest.fn(),
}; };
const mockStructureService = {
findOne: jest.fn(),
deleteOne: jest.fn(),
findAll: jest.fn(),
getAllUserCompletedStructures: jest.fn(),
findAllUnclaimed: jest.fn(),
};
const mockAdminService = {
isDateOutdated: jest.fn(),
getLastUpdateDate: jest.fn(),
};
const pendingStructureTest: PendingStructureDto = { const pendingStructureTest: PendingStructureDto = {
structureId: new Types.ObjectId('6093ba0e2ab5775cfc01ed3e'), structureId: new Types.ObjectId('6093ba0e2ab5775cfc01ed3e'),
structureName: 'test', structureName: 'test',
...@@ -82,7 +97,7 @@ describe('AdminController', () => { ...@@ -82,7 +97,7 @@ describe('AdminController', () => {
}, },
{ {
provide: StructuresService, provide: StructuresService,
useClass: StructuresServiceMock, useValue: mockStructureService,
}, },
{ {
provide: NewsletterService, provide: NewsletterService,
...@@ -90,7 +105,7 @@ describe('AdminController', () => { ...@@ -90,7 +105,7 @@ describe('AdminController', () => {
}, },
{ {
provide: AdminService, provide: AdminService,
useClass: AdminService, useValue: mockAdminService,
}, },
StructuresSearchService, StructuresSearchService,
MailerService, MailerService,
...@@ -132,28 +147,30 @@ describe('AdminController', () => { ...@@ -132,28 +147,30 @@ describe('AdminController', () => {
.useValue(mockRoleGuard) .useValue(mockRoleGuard)
.compile(); .compile();
controller = module.get<AdminController>(AdminController); adminController = module.get<AdminController>(AdminController);
userService = module.get<UsersService>(UsersService); userService = module.get<UsersService>(UsersService);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(controller).toBeDefined(); expect(adminController).toBeDefined();
}); });
it('should get pending attachments', async () => { it('should get pending attachments', async () => {
expect((await controller.getPendingAttachments()).length).toBe(2); mockStructureService.findOne.mockResolvedValue({ structureName: 'structure', updatedAt: '' });
expect(Object.keys((await controller.getPendingAttachments())[0]).length).toBe(5); expect((await adminController.getPendingAttachments()).length).toBe(2);
expect(Object.keys((await adminController.getPendingAttachments())[0]).length).toBe(5);
}); });
describe('Pending structures validation', () => { describe('Pending structures validation', () => {
it('should validate pending structure', async () => { it('should validate pending structure', async () => {
expect((await controller.validatePendingStructure(pendingStructureTest)).length).toBe(2); mockStructureService.findOne.mockResolvedValue({ structureName: 'structure' });
expect(Object.keys((await controller.validatePendingStructure(pendingStructureTest))[0]).length).toBe(5); expect((await adminController.validatePendingStructure(pendingStructureTest)).length).toBe(2);
expect(Object.keys((await adminController.validatePendingStructure(pendingStructureTest))[0]).length).toBe(5);
}); });
it('should get structure does not exist', async () => { it('should get structure does not exist', async () => {
try { try {
await controller.validatePendingStructure(pendingStructureTest); await adminController.validatePendingStructure(pendingStructureTest);
} catch (e) { } catch (e) {
expect(e.message).toBe('Structure does not exist'); expect(e.message).toBe('Structure does not exist');
expect(e.status).toBe(404); expect(e.status).toBe(404);
...@@ -163,13 +180,14 @@ describe('AdminController', () => { ...@@ -163,13 +180,14 @@ describe('AdminController', () => {
describe('Pending structures cancel', () => { describe('Pending structures cancel', () => {
it('should refuse pending structure', async () => { it('should refuse pending structure', async () => {
expect((await controller.refusePendingStructure(pendingStructureTest)).length).toBe(2); mockStructureService.findOne.mockResolvedValue({ structureName: 'structure' });
expect(Object.keys((await controller.refusePendingStructure(pendingStructureTest))[0]).length).toBe(5); expect((await adminController.refusePendingStructure(pendingStructureTest)).length).toBe(2);
expect(Object.keys((await adminController.refusePendingStructure(pendingStructureTest))[0]).length).toBe(5);
}); });
it('should get structure does not exist', async () => { it('should get structure does not exist', async () => {
try { try {
await controller.refusePendingStructure(pendingStructureTest); await adminController.refusePendingStructure(pendingStructureTest);
} catch (e) { } catch (e) {
expect(e.message).toBe('Structure does not exist'); expect(e.message).toBe('Structure does not exist');
expect(e.status).toBe(404); expect(e.status).toBe(404);
...@@ -179,11 +197,13 @@ describe('AdminController', () => { ...@@ -179,11 +197,13 @@ describe('AdminController', () => {
describe('Delete user', () => { describe('Delete user', () => {
it('should delete user', async () => { it('should delete user', async () => {
expect((await controller.deleteUser({ id: 'tsfsf6296' })).email).toBe('pauline.dupont@mii.com'); jest.spyOn(StructuresServiceMock.prototype, 'deleteOne').mockImplementationOnce(() => null);
const user = await adminController.deleteUser({ id: 'tsfsf6296' });
expect(user.email).toBe('pauline.dupont@mii.com');
}); });
it('should return unexisting user', async () => { it('should return nonexisting user', async () => {
try { try {
await controller.deleteUser({ id: 'userdoesnotexist' }); await adminController.deleteUser({ id: 'userDoesNotExist' });
} catch (e) { } catch (e) {
expect(e.message).toBe('Invalid user id'); expect(e.message).toBe('Invalid user id');
expect(e.status).toBe(400); expect(e.status).toBe(400);
...@@ -201,7 +221,7 @@ describe('AdminController', () => { ...@@ -201,7 +221,7 @@ describe('AdminController', () => {
validated: true, validated: true,
}; };
mockEmployerService.findOne.mockResolvedValueOnce(mockEmployer); mockEmployerService.findOne.mockResolvedValueOnce(mockEmployer);
const reply = await controller.setUserEmployer({ const reply = await adminController.setUserEmployer({
userId: mockUserId, userId: mockUserId,
employerId: String(mockEmployer._id), employerId: String(mockEmployer._id),
}); });
...@@ -220,7 +240,7 @@ describe('AdminController', () => { ...@@ -220,7 +240,7 @@ describe('AdminController', () => {
}; };
mockEmployerService.findOne.mockResolvedValueOnce(null); mockEmployerService.findOne.mockResolvedValueOnce(null);
try { try {
await controller.setUserEmployer({ await adminController.setUserEmployer({
userId: mockUserId, userId: mockUserId,
employerId: String(mockEmployer._id), employerId: String(mockEmployer._id),
}); });
...@@ -234,7 +254,7 @@ describe('AdminController', () => { ...@@ -234,7 +254,7 @@ describe('AdminController', () => {
it('should not set a new employer to the user if the user does not exist', async () => { it('should not set a new employer to the user if the user does not exist', async () => {
const spyer = jest.spyOn(userService, 'updateUserEmployer'); const spyer = jest.spyOn(userService, 'updateUserEmployer');
const mockUserId = 'thisuserdoesnotexist'; const mockUserId = 'thisUserDoesNotExist';
const mockEmployer = { const mockEmployer = {
_id: new Types.ObjectId('6231aefe76598527c8d0b5ba'), _id: new Types.ObjectId('6231aefe76598527c8d0b5ba'),
name: 'Sopra', name: 'Sopra',
...@@ -242,7 +262,7 @@ describe('AdminController', () => { ...@@ -242,7 +262,7 @@ describe('AdminController', () => {
}; };
mockEmployerService.findOne.mockResolvedValueOnce(mockEmployer); mockEmployerService.findOne.mockResolvedValueOnce(mockEmployer);
try { try {
await controller.setUserEmployer({ await adminController.setUserEmployer({
userId: mockUserId, userId: mockUserId,
employerId: String(mockEmployer._id), employerId: String(mockEmployer._id),
}); });
...@@ -265,7 +285,7 @@ describe('AdminController', () => { ...@@ -265,7 +285,7 @@ describe('AdminController', () => {
validated: true, validated: true,
}; };
mockJobService.findOne.mockResolvedValueOnce(mockJob); mockJobService.findOne.mockResolvedValueOnce(mockJob);
const reply = await controller.setUserJob({ const reply = await adminController.setUserJob({
userId: mockUserId, userId: mockUserId,
jobId: String(mockJob._id), jobId: String(mockJob._id),
}); });
...@@ -284,7 +304,7 @@ describe('AdminController', () => { ...@@ -284,7 +304,7 @@ describe('AdminController', () => {
}; };
mockJobService.findOne.mockResolvedValueOnce(null); mockJobService.findOne.mockResolvedValueOnce(null);
try { try {
await controller.setUserJob({ await adminController.setUserJob({
userId: mockUserId, userId: mockUserId,
jobId: String(mockJob._id), jobId: String(mockJob._id),
}); });
...@@ -306,7 +326,7 @@ describe('AdminController', () => { ...@@ -306,7 +326,7 @@ describe('AdminController', () => {
}; };
mockJobService.findOne.mockResolvedValueOnce(mockJob); mockJobService.findOne.mockResolvedValueOnce(mockJob);
try { try {
await controller.setUserJob({ await adminController.setUserJob({
userId: mockUserId, userId: mockUserId,
jobId: String(mockJob._id), jobId: String(mockJob._id),
}); });
...@@ -321,57 +341,78 @@ describe('AdminController', () => { ...@@ -321,57 +341,78 @@ describe('AdminController', () => {
describe('Search user', () => { describe('Search user', () => {
it('should return all users, empty string', async () => { it('should return all users, empty string', async () => {
expect((await controller.searchUsers({ searchString: '' })).length).toBe(2); expect((await adminController.searchUsers({ searchString: '' })).length).toBe(2);
}); });
it('should return all users, null input', async () => { it('should return all users, null input', async () => {
expect((await controller.searchUsers({ searchString: null })).length).toBe(2); expect((await adminController.searchUsers({ searchString: null })).length).toBe(2);
}); });
it('should one user', async () => { it('should one user', async () => {
expect((await controller.searchUsers({ searchString: 'a@a.com' })).length).toBe(1); expect((await adminController.searchUsers({ searchString: 'a@a.com' })).length).toBe(1);
expect((await controller.searchUsers({ searchString: 'a@a.com' }))[0].email).toBe('a@a.com'); expect((await adminController.searchUsers({ searchString: 'a@a.com' }))[0].email).toBe('a@a.com');
}); });
it('should no user', async () => { it('should no user', async () => {
expect((await controller.searchUsers({ searchString: 'dfqfqsfqfqfa@a.com' })).length).toBe(0); expect((await adminController.searchUsers({ searchString: 'dfqfqsfqfqfa@a.com' })).length).toBe(0);
}); });
}); });
describe('Search delete a user subscription', () => { describe('Search delete a user subscription', () => {
it('should return a deleted object', async () => { it('should return a deleted object', async () => {
expect((await controller.unsubscribeUserFromNewsletter('a@a.com')).email).toBe('a@a.com'); expect((await adminController.unsubscribeUserFromNewsletter('a@a.com')).email).toBe('a@a.com');
expect(Object.keys(await controller.unsubscribeUserFromNewsletter('a@a.com')).length).toBe(4); expect(Object.keys(await adminController.unsubscribeUserFromNewsletter('a@a.com')).length).toBe(4);
}); });
it('should throw an error', async () => { it('should throw an error', async () => {
try { try {
await controller.unsubscribeUserFromNewsletter('test@test.com'); await adminController.unsubscribeUserFromNewsletter('test@test.com');
} catch (e) { } catch (e) {
expect(e.message).toBe('Invalid email'); expect(e.message).toBe('Invalid email');
expect(e.status).toBe(401); expect(e.status).toBe(401);
} }
}); });
}); });
it('should get pending structure list for admin', async () => { it('should get pending structure list for admin', async () => {
expect((await controller.getAdminStructuresList()).inClaim.length).toBe(2); mockAdminService.isDateOutdated.mockReturnValue(false);
expect((await controller.getAdminStructuresList()).toClaim.length).toEqual(2); mockAdminService.getLastUpdateDate.mockReturnValue('');
expect((await controller.getAdminStructuresList()).claimed.length).toEqual(2); mockStructureService.findOne.mockResolvedValue({ structureName: 'structure' });
expect((await controller.getAdminStructuresList()).incomplete.length).toEqual(2); // using _id for unclaimed
mockStructureService.findAllUnclaimed.mockResolvedValueOnce([
{ structureName: 'name', structureId: 'a', _id: 'a' },
{ structureName: 'name', structureId: 'b', _id: 'b' },
]);
mockStructureService.findAll.mockResolvedValueOnce([
{ structureName: 'name', structureId: 'c' },
{ structureName: 'name', structureId: 'd' },
]);
mockStructureService.findAll.mockResolvedValueOnce([
{ structureName: 'name', structureId: 'e', id: 'e' },
{ structureName: 'name', structureId: 'f', id: 'f' },
]);
const adminList = await adminController.getAdminStructuresList();
expect(adminList.inClaim.length).toBe(2);
expect(adminList.toClaim.length).toBe(2);
expect(adminList.claimed.length).toBe(2);
expect(adminList.incomplete.length).toBe(2);
}); });
it('should find attached users', async () => { it('should find attached users', async () => {
expect((await controller.findAttachedUsers()).length).toBe(0); mockStructureService.getAllUserCompletedStructures.mockResolvedValueOnce([]);
expect((await adminController.findAttachedUsers()).length).toBe(0);
}); });
it('should find unattached users', async () => { it('should find unattached users', async () => {
expect((await controller.findUnattachedUsers()).length).toBe(0); expect((await adminController.findUnattachedUsers()).length).toBe(0);
}); });
it('should find unverified users', async () => { it('should find unverified users', async () => {
expect((await controller.findUnVerifiedUsers()).length).toBe(0); mockStructureService.getAllUserCompletedStructures.mockResolvedValueOnce([]);
expect((await adminController.findUnVerifiedUsers()).length).toBe(0);
}); });
describe('should test getDeletedStructures()', () => { describe('should test getDeletedStructures()', () => {
it('should find getDeletedStructures', async () => { it('should find getDeletedStructures', async () => {
expect((await controller.getDeletedStructures()).length).toBeGreaterThan(0); mockStructureService.findAll.mockResolvedValue(structuresDocumentDataMock);
expect((await adminController.getDeletedStructures()).length).toBeGreaterThan(0);
}); });
}); });
}); });
...@@ -14,6 +14,8 @@ import { ...@@ -14,6 +14,8 @@ import {
import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
import { validate } from 'class-validator'; import { validate } from 'class-validator';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { EspaceCoopCNFS } from '../espaceCoop/schemas/espaceCoopCNFS.schema';
import { EspaceCoopService } from '../espaceCoop/services/espaceCoop.service';
import { NewsletterSubscription } from '../newsletter/newsletter-subscription.schema'; import { NewsletterSubscription } from '../newsletter/newsletter-subscription.schema';
import { NewsletterService } from '../newsletter/newsletter.service'; import { NewsletterService } from '../newsletter/newsletter.service';
import { Structure, StructureDocument } from '../structures/schemas/structure.schema'; import { Structure, StructureDocument } from '../structures/schemas/structure.schema';
...@@ -28,8 +30,6 @@ import { AdminService } from './admin.service'; ...@@ -28,8 +30,6 @@ import { AdminService } from './admin.service';
import { PendingStructureDto } from './dto/pending-structure.dto'; import { PendingStructureDto } from './dto/pending-structure.dto';
import { SetUserEmployerDto } from './dto/set-user-employer.dto'; import { SetUserEmployerDto } from './dto/set-user-employer.dto';
import { SetUserJobDto } from './dto/set-user-job.dto'; import { SetUserJobDto } from './dto/set-user-job.dto';
import { EspaceCoopCNFS } from '../espaceCoop/schemas/espaceCoopCNFS.schema';
import { EspaceCoopService } from '../espaceCoop/services/espaceCoop.service';
@ApiTags('admin') @ApiTags('admin')
@Controller('admin') @Controller('admin')
...@@ -368,7 +368,7 @@ export class AdminController { ...@@ -368,7 +368,7 @@ export class AdminController {
@ApiOperation({ description: 'Get deleted structures' }) @ApiOperation({ description: 'Get deleted structures' })
@Post('restoreDeletedStructure/:structureId') @Post('restoreDeletedStructure/:structureId')
public async restoreDeletedStructures(@Param('structureId') structureId: string): Promise<void> { public async restoreDeletedStructures(@Param('structureId') structureId: string): Promise<void> {
this.logger.debug(`restoreDeletedStructures: ${structureId}`); this.logger.log(`restoreDeletedStructures: ${structureId}`);
await this.structuresService.restoreStructure(structureId); await this.structuresService.restoreStructure(structureId);
await this.structuresService.initiateStructureIndex(); await this.structuresService.initiateStructureIndex();
} }
......
...@@ -2,17 +2,17 @@ import { Test, TestingModule } from '@nestjs/testing'; ...@@ -2,17 +2,17 @@ import { Test, TestingModule } from '@nestjs/testing';
import { AdminService } from './admin.service'; import { AdminService } from './admin.service';
describe('AdminService', () => { describe('AdminService', () => {
let service: AdminService; let adminService: AdminService;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
providers: [AdminService], providers: [AdminService],
}).compile(); }).compile();
service = module.get<AdminService>(AdminService); adminService = module.get<AdminService>(AdminService);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(service).toBeDefined(); expect(adminService).toBeDefined();
}); });
}); });
...@@ -6,7 +6,7 @@ import { Appointment } from './appointment.schema'; ...@@ -6,7 +6,7 @@ import { Appointment } from './appointment.schema';
import { AppointmentService } from './appointment.service'; import { AppointmentService } from './appointment.service';
describe('UserRegistryController', () => { describe('UserRegistryController', () => {
let controller: AppointmentController; let appoinmentController: AppointmentController;
const appointmentServiceMock = { const appointmentServiceMock = {
findAll: jest.fn(), findAll: jest.fn(),
...@@ -29,24 +29,24 @@ describe('UserRegistryController', () => { ...@@ -29,24 +29,24 @@ describe('UserRegistryController', () => {
controllers: [AppointmentController], controllers: [AppointmentController],
}).compile(); }).compile();
controller = module.get<AppointmentController>(AppointmentController); appoinmentController = module.get<AppointmentController>(AppointmentController);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(controller).toBeDefined(); expect(appoinmentController).toBeDefined();
}); });
describe('findAll', () => { describe('findAll', () => {
it('should findAll entries', async () => { it('should findAll entries', async () => {
appointmentServiceMock.findAll.mockResolvedValue(appointmentMockData); appointmentServiceMock.findAll.mockResolvedValue(appointmentMockData);
const reply = await controller.findAll(); const reply = await appoinmentController.findAll();
expect(reply).toStrictEqual(appointmentMockData); expect(reply).toStrictEqual(appointmentMockData);
}); });
}); });
describe('createAppointment', () => { describe('createAppointment', () => {
it('should create a new entry', async () => { it('should create a new entry', async () => {
appointmentServiceMock.create.mockResolvedValue(singleAppointmentMock); appointmentServiceMock.create.mockResolvedValue(singleAppointmentMock);
const reply = await controller.createAppointment(singleAppointmentMock); const reply = await appoinmentController.createAppointment(singleAppointmentMock);
expect(reply).toStrictEqual(singleAppointmentMock); expect(reply).toStrictEqual(singleAppointmentMock);
}); });
}); });
......
import { HttpModule } from '@nestjs/axios';
import { getModelToken } from '@nestjs/mongoose'; import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { AppointmentService } from './appointment.service'; import * as ejs from 'ejs';
import { appointmentMockData } from '../../test/mock/data/appointment.mock.data'; import { appointmentMockData } from '../../test/mock/data/appointment.mock.data';
import { MailerService } from '../mailer/mailer.service'; import { StructuresServiceMock } from '../../test/mock/services/structures.mock.service';
import { UsersServiceMock } from '../../test/mock/services/user.mock.service';
import { MailerModule } from '../mailer/mailer.module'; import { MailerModule } from '../mailer/mailer.module';
import { HttpModule } from '@nestjs/axios'; import { MailerService } from '../mailer/mailer.service';
import { UsersService } from '../users/services/users.service';
import { StructuresService } from '../structures/services/structures.service'; import { StructuresService } from '../structures/services/structures.service';
import { UsersServiceMock } from '../../test/mock/services/user.mock.service'; import { UsersService } from '../users/services/users.service';
import { StructuresServiceMock } from '../../test/mock/services/structures.mock.service'; import { AppointmentService } from './appointment.service';
import * as ejs from 'ejs';
jest.mock('ejs');
describe('userRegistryService', () => { describe('userRegistryService', () => {
let service: AppointmentService; let appointmentService: AppointmentService;
const mockAppointmentModel = { const mockAppointmentModel = {
find: jest.fn(() => mockAppointmentModel), find: jest.fn(() => mockAppointmentModel),
create: jest.fn(() => mockAppointmentModel), create: jest.fn(() => mockAppointmentModel),
...@@ -36,7 +36,6 @@ describe('userRegistryService', () => { ...@@ -36,7 +36,6 @@ describe('userRegistryService', () => {
}; };
const ejsSpy = jest.spyOn(ejs, 'renderFile'); const ejsSpy = jest.spyOn(ejs, 'renderFile');
const mailerSpy = jest.spyOn(mockMailService, 'send');
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
...@@ -58,17 +57,17 @@ describe('userRegistryService', () => { ...@@ -58,17 +57,17 @@ describe('userRegistryService', () => {
}, },
], ],
}).compile(); }).compile();
service = module.get<AppointmentService>(AppointmentService); appointmentService = module.get<AppointmentService>(AppointmentService);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(service).toBeDefined(); expect(appointmentService).toBeDefined();
}); });
describe('findAll', () => { describe('findAll', () => {
it('should findAll entries', async () => { it('should findAll entries', async () => {
mockAppointmentModel.exec.mockResolvedValueOnce(appointmentMockData); mockAppointmentModel.exec.mockResolvedValueOnce(appointmentMockData);
expect(await service.findAll()).toBe(appointmentMockData); expect(await appointmentService.findAll()).toBe(appointmentMockData);
}); });
}); });
describe('create', () => { describe('create', () => {
...@@ -76,7 +75,7 @@ describe('userRegistryService', () => { ...@@ -76,7 +75,7 @@ describe('userRegistryService', () => {
const res = { const res = {
accompanimentType: 'RDV Conseiller Numérique', accompanimentType: 'RDV Conseiller Numérique',
name: 'test', name: 'test',
onlineDemarcheType: ['Démarches Métropolitaines', 'CPAM'], onlineDemarcheType: ['Démarches Métropolitaines'],
phone: '65 65', phone: '65 65',
surname: 'teztrfzegfv', surname: 'teztrfzegfv',
structureOrientator: { structureName: 'name', structureMail: 'mail@structure.org', structurePhone: '12 34' }, structureOrientator: { structureName: 'name', structureMail: 'mail@structure.org', structurePhone: '12 34' },
...@@ -86,8 +85,8 @@ describe('userRegistryService', () => { ...@@ -86,8 +85,8 @@ describe('userRegistryService', () => {
mockMailService.loadJsonConfig.mockReturnValueOnce({ subject: 'Teste Mail' }); mockMailService.loadJsonConfig.mockReturnValueOnce({ subject: 'Teste Mail' });
ejsSpy.mockResolvedValueOnce('coucou'); ejsSpy.mockResolvedValueOnce('coucou');
mockAppointmentModel.create.mockResolvedValueOnce(res); mockAppointmentModel.create.mockResolvedValueOnce(res);
expect(await service.create(res)).toStrictEqual(res); expect(await appointmentService.create(res)).toStrictEqual(res);
expect(mailerSpy).toHaveBeenCalledTimes(1); expect(mockMailService.send).toHaveBeenCalledTimes(1);
}); });
}); });
}); });
...@@ -18,7 +18,7 @@ export class AppointmentDto { ...@@ -18,7 +18,7 @@ export class AppointmentDto {
@IsNotEmpty() @IsNotEmpty()
@ApiProperty({ @ApiProperty({
example: [{ text: 'CAF' }, { text: 'CPAM' }], example: [{ text: 'CAF' }, { text: 'France Connect' }],
}) })
readonly onlineDemarcheType: string[]; readonly onlineDemarcheType: string[];
......
import { HttpService } from '@nestjs/axios';
import { JwtModule } from '@nestjs/jwt'; import { JwtModule } from '@nestjs/jwt';
import { getModelToken } from '@nestjs/mongoose'; import { getModelToken } from '@nestjs/mongoose';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { AuthServiceMock } from '../../test/mock/services/auth.mock.service'; import { AuthServiceMock } from '../../test/mock/services/auth.mock.service';
import { StructuresServiceMock } from '../../test/mock/services/structures.mock.service';
import { CategoriesService } from '../categories/services/categories.service';
import { ConfigurationModule } from '../configuration/configuration.module'; import { ConfigurationModule } from '../configuration/configuration.module';
import { MailerModule } from '../mailer/mailer.module'; import { MailerModule } from '../mailer/mailer.module';
import { StructuresSearchService } from '../structures/services/structures-search.service';
import { StructuresService } from '../structures/services/structures.service';
import { Job } from '../users/schemas/job.schema';
import { User } from '../users/schemas/user.schema'; import { User } from '../users/schemas/user.schema';
import { JobsService } from '../users/services/jobs.service';
import { UserRegistrySearchService } from '../users/services/userRegistry-search.service'; import { UserRegistrySearchService } from '../users/services/userRegistry-search.service';
import { UsersService } from '../users/services/users.service'; import { UsersService } from '../users/services/users.service';
import { AuthController } from './auth.controller'; import { AuthController } from './auth.controller';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { LoginDto } from './login-dto'; import { LoginDto } from './login-dto';
import { JobsService } from '../users/services/jobs.service';
import { Job } from '../users/schemas/job.schema';
import { StructuresService } from '../structures/services/structures.service';
import { HttpService } from '@nestjs/axios';
import { StructuresSearchService } from '../structures/services/structures-search.service';
import { CategoriesService } from '../categories/services/categories.service';
import { StructuresServiceMock } from '../../test/mock/services/structures.mock.service';
describe('AuthController', () => { describe('AuthController', () => {
let controller: AuthController; let authController: AuthController;
const httpServiceMock = { const httpServiceMock = {
get: jest.fn(), get: jest.fn(),
...@@ -83,16 +83,16 @@ describe('AuthController', () => { ...@@ -83,16 +83,16 @@ describe('AuthController', () => {
], ],
}).compile(); }).compile();
controller = module.get<AuthController>(AuthController); authController = module.get<AuthController>(AuthController);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(controller).toBeDefined(); expect(authController).toBeDefined();
}); });
it('should login valid user', async () => { it('should login valid user', async () => {
const loginCredentials: LoginDto = { email: 'paula.dubois@mii.com', password: process.env.USER_PWD }; const loginCredentials: LoginDto = { email: 'paula.dubois@mii.com', password: process.env.USER_PWD };
const result = await controller.login(loginCredentials); const result = await authController.login(loginCredentials);
expect(result).toStrictEqual({ expect(result).toStrictEqual({
_id: 'tsfsf6296', _id: 'tsfsf6296',
email: 'pauline.dupont@mii.com', email: 'pauline.dupont@mii.com',
...@@ -109,7 +109,7 @@ describe('AuthController', () => { ...@@ -109,7 +109,7 @@ describe('AuthController', () => {
it('should not login invalid user', async () => { it('should not login invalid user', async () => {
const loginCredentials: LoginDto = { email: 'jacques.dupont@mii.com', password: process.env.USER_PWD }; const loginCredentials: LoginDto = { email: 'jacques.dupont@mii.com', password: process.env.USER_PWD };
try { try {
await controller.login(loginCredentials); await authController.login(loginCredentials);
} catch (e) { } catch (e) {
expect(e.response).toBe('Invalid credentials'); expect(e.response).toBe('Invalid credentials');
expect(e.message).toBe('Invalid credentials'); expect(e.message).toBe('Invalid credentials');
......
...@@ -10,7 +10,7 @@ import { AuthService } from './auth.service'; ...@@ -10,7 +10,7 @@ import { AuthService } from './auth.service';
import { LoginDto } from './login-dto'; import { LoginDto } from './login-dto';
describe('AuthService', () => { describe('AuthService', () => {
let service: AuthService; let authService: AuthService;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
...@@ -28,11 +28,11 @@ describe('AuthService', () => { ...@@ -28,11 +28,11 @@ describe('AuthService', () => {
], ],
}).compile(); }).compile();
service = module.get<AuthService>(AuthService); authService = module.get<AuthService>(AuthService);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(service).toBeDefined(); expect(authService).toBeDefined();
}); });
describe('validateUser', () => { describe('validateUser', () => {
...@@ -47,12 +47,12 @@ describe('AuthService', () => { ...@@ -47,12 +47,12 @@ describe('AuthService', () => {
personalOffers: [], personalOffers: [],
}; };
const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR
expect(await service.validateUser(loginDto)).toStrictEqual(result); expect(await authService.validateUser(loginDto)).toStrictEqual(result);
}); });
it('should not validateUser', async () => { it('should not validateUser', async () => {
const loginDto: LoginDto = { email: 'tom.dupont@mii.com', password: 'test1A!!!' }; //NOSONAR const loginDto: LoginDto = { email: 'tom.dupont@mii.com', password: 'test1A!!!' }; //NOSONAR
expect(await service.validateUser(loginDto)).toBe(null); expect(await authService.validateUser(loginDto)).toBe(null);
}); });
}); });
...@@ -71,7 +71,7 @@ describe('AuthService', () => { ...@@ -71,7 +71,7 @@ describe('AuthService', () => {
_createToken.mockImplementation(() => token); _createToken.mockImplementation(() => token);
const loginDto: LoginDto = { email: 'pauline.dupont@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'pauline.dupont@mii.com', password: 'test1A!!' }; //NOSONAR
expect(await service.login(loginDto)).toStrictEqual({ expect(await authService.login(loginDto)).toStrictEqual({
accessToken: accessToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4',
expiresAt: '2021-05-04T15:35:06.663+02:00', expiresAt: '2021-05-04T15:35:06.663+02:00',
...@@ -92,7 +92,7 @@ describe('AuthService', () => { ...@@ -92,7 +92,7 @@ describe('AuthService', () => {
const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR
try { try {
await service.login(loginDto); await authService.login(loginDto);
} catch (e) { } catch (e) {
expect(e.response).toBe('Invalid credentials'); expect(e.response).toBe('Invalid credentials');
expect(e.message).toBe('Invalid credentials'); expect(e.message).toBe('Invalid credentials');
...@@ -111,7 +111,7 @@ describe('AuthService', () => { ...@@ -111,7 +111,7 @@ describe('AuthService', () => {
const loginDto: LoginDto = { email: 'toto@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'toto@mii.com', password: 'test1A!!' }; //NOSONAR
try { try {
await service.login(loginDto); await authService.login(loginDto);
} catch (e) { } catch (e) {
expect(e.response).toBe('Invalid credentials'); expect(e.response).toBe('Invalid credentials');
expect(e.message).toBe('Invalid credentials'); expect(e.message).toBe('Invalid credentials');
...@@ -130,7 +130,7 @@ describe('AuthService', () => { ...@@ -130,7 +130,7 @@ describe('AuthService', () => {
const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: '1' }; //NOSONAR const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: '1' }; //NOSONAR
try { try {
await service.login(loginDto); await authService.login(loginDto);
} catch (e) { } catch (e) {
expect(e.response).toBe('Invalid credentials'); expect(e.response).toBe('Invalid credentials');
expect(e.message).toBe('Invalid credentials'); expect(e.message).toBe('Invalid credentials');
......
...@@ -10,7 +10,7 @@ import { CategoriesService } from '../services/categories.service'; ...@@ -10,7 +10,7 @@ import { CategoriesService } from '../services/categories.service';
import { CategoriesController } from './categories.controller'; import { CategoriesController } from './categories.controller';
describe('CategoriesAccompagnementController', () => { describe('CategoriesAccompagnementController', () => {
let controller: CategoriesController; let categoriesController: CategoriesController;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
...@@ -33,15 +33,15 @@ describe('CategoriesAccompagnementController', () => { ...@@ -33,15 +33,15 @@ describe('CategoriesAccompagnementController', () => {
.useValue(mockRoleGuard) .useValue(mockRoleGuard)
.compile(); .compile();
controller = module.get<CategoriesController>(CategoriesController); categoriesController = module.get<CategoriesController>(CategoriesController);
}); });
it('should be defined', () => { it('should be defined', () => {
expect(controller).toBeDefined(); expect(categoriesController).toBeDefined();
}); });
it('should find all accompagnements', async () => { it('should find all accompagnements', async () => {
expect((await controller.findAll()).length).toBe(1); expect((await categoriesController.findAll()).length).toBe(1);
expect((await controller.findAll())[0].modules.length).toBe(8); expect((await categoriesController.findAll())[0].modules.length).toBe(7);
}); });
}); });