diff --git a/src/online-mediation/onlineMediation.service.spec.ts b/src/online-mediation/onlineMediation.service.spec.ts index 264fd8e4a92924cb115ea05c3da0236e9bdc5436..305dfba6bba2fae641f433ad4056ae11ab3cf402 100644 --- a/src/online-mediation/onlineMediation.service.spec.ts +++ b/src/online-mediation/onlineMediation.service.spec.ts @@ -94,7 +94,7 @@ describe('userRegistryService', () => { expect(mailerSpy).toHaveBeenCalledTimes(1); expect(response).toBe(onlineMediationMockData.length); }); - it('should send the mail and reset db', async () => { + it('should NOT send the mail and reset db', async () => { mockConfigService.isProdConf.mockReturnValueOnce(false); mockOnlineMediationModel.exec.mockResolvedValueOnce(onlineMediationMockData); mockOnlineMediationModel.deleteMany.mockReturnThis(); diff --git a/src/personal-offers/personal-offers.controller.spec.ts b/src/personal-offers/personal-offers.controller.spec.ts index 50fe471bbea755145c42964d1c2f442f2465f86e..5f4cc657ee7225440e8825fb6fc2bf2050cbea2e 100644 --- a/src/personal-offers/personal-offers.controller.spec.ts +++ b/src/personal-offers/personal-offers.controller.spec.ts @@ -137,7 +137,7 @@ describe('PersonalOffersController', () => { }); }); - describe('update personal offer', () => { + describe('delete personal offer', () => { it('should get deleted personal offer', async () => { expect(await personalOffersController.delete('2345ba0e2ab5775cfc01ed4d')).toEqual(personalOffersDataMock[1]); }); diff --git a/src/structures/services/structures.service.spec.ts b/src/structures/services/structures.service.spec.ts index b0a24bdc6e0dd371a251900afc8e4fb9315d8c1f..05da523c9ee6e1e9ab6124d6cd3f76b35effb620 100644 --- a/src/structures/services/structures.service.spec.ts +++ b/src/structures/services/structures.service.spec.ts @@ -303,6 +303,7 @@ describe('StructuresService', () => { mockStructureModel.exec.mockResolvedValue([ { _id: '6903ba0e2ab5775cfc01ed4d', + structureName: "L'Atelier Numérique", structureId: '6903ba0e2ab5775cfc01ed4d', structureType: null, digitalCultureSecurity: ['2', '5', '9', '28', '34', '39', '42', '51', '52', '54', '65', '96', '97', '98'], @@ -317,7 +318,6 @@ describe('StructuresService', () => { freeWorkShop: 'Non', createdAt: '2020-11-16T09:30:00.000Z', updatedAt: '2021-04-12T08:48:00.000Z', - structureName: "L'Atelier Numérique", description: "L'Atelier Numérique est l'Espace Public Numérique des Centres Sociaux de Rillieux-la-Pape, ayant pour mission la médiation numérique pour toutes et tous.", lockdownActivity: @@ -371,14 +371,6 @@ describe('StructuresService', () => { }, ]); - it('should find 1 structure', async () => { - const res = await structureService.searchForStructures('a', [[{ nbPrinters: '1' }]]); - expect(res.length).toBe(1); - }); - it('should find 1 structure', async () => { - const res = await structureService.searchForStructures('a', [[{ nbPrinters: '1' }, { onlineProcedures: 'caf' }]]); - expect(res.length).toBe(1); - }); it('should find 0 structure with personalOffer', async () => { const res = await structureService.searchForStructures('a', [[{ onlineProcedures: 'caf' }]], null, true); expect(res.length).toBe(0); diff --git a/src/users/controllers/employer.controller.spec.ts b/src/users/controllers/employer.controller.spec.ts index 5f5c13d383da03e1f0ba117d33bd8898658f461c..9ed7c5fdde86e0fd206124dd024eda86d7eecec8 100644 --- a/src/users/controllers/employer.controller.spec.ts +++ b/src/users/controllers/employer.controller.spec.ts @@ -9,6 +9,7 @@ import { Employer } from '../schemas/employer.schema'; import { EmployerService } from '../services/employer.service'; import { UsersService } from '../services/users.service'; import { EmployerController } from './employer.controller'; +import { CreateEmployerDto } from '../dto/create-employer.dto'; describe('EmployerController', () => { let employerController: EmployerController; @@ -93,40 +94,6 @@ describe('EmployerController', () => { }); }); - // describe('deleteEmployer', () => { - // it('should delete employer `Metro`', async () => { - // const employer: Employer = { - // name: 'Metro', - // validated: true, - // }; - // const employerToRemove: CreateEmployerDto = { - // name: 'Metro', - // }; - // employerServiceMock.findByName.mockResolvedValueOnce(employer); - // employerServiceMock.deleteByName.mockResolvedValueOnce({ - // ok: 1, - // n: 1, - // deletedCount: 1, - // }); - // const deleteEmployer = await controller.deleteEmployer(employerToRemove); - // expect(deleteEmployer.name).toBe('Metro'); - // expect(deleteEmployer.validated).toBe(true); - // }); - - // it('should throw error on unexisting employer `Metro`', async () => { - // const employerToRemove: CreateEmployerDto = { - // name: 'Metro', - // }; - // employerServiceMock.deleteByName.mockResolvedValueOnce(null); - // try { - // await controller.deleteEmployer(employerToRemove); - // expect(true).toBe(false); - // } catch (e) { - // expect(e.message).toBe('Employer does not exist'); - // expect(e.status).toBe(404); - // } - // }); - // }); describe('resetES', () => { it('should reset search index', async () => { employerServiceMock.initEmployerIndex.mockResolvedValueOnce([ diff --git a/src/users/services/employer-search.service.spec.ts b/src/users/services/employer-search.service.spec.ts index 435428dee0036b8dc65527fa82f07ced79c32f56..2f56eb94190fb367c73882731407790d5db19f17 100644 --- a/src/users/services/employer-search.service.spec.ts +++ b/src/users/services/employer-search.service.spec.ts @@ -54,15 +54,9 @@ describe('EmployerSearchService Search cases', () => { }, 10000); it('should be defined', async () => { - // await new Promise((r) => setTimeout(r, 9000)); expect(employerSearchService).toBeDefined(); }); - // it('should index structures', async () => { - // // but we still need to wait the refresh to be done - // await new Promise((r) => setTimeout(r, 2000)); - // }, 10000); - it('should find Metro', async () => { const res = await employerSearchService.search('Metro'); expect(res[0].name).toBe('Metro'); diff --git a/src/users/services/employer.service.spec.ts b/src/users/services/employer.service.spec.ts index 81567808e3880ae36548c24b00e5fa70ef062f70..2c2c04cf7443a5dac274a0a9fd5ee4bd5421a65d 100644 --- a/src/users/services/employer.service.spec.ts +++ b/src/users/services/employer.service.spec.ts @@ -133,7 +133,7 @@ describe('EmployerService', () => { }, ]); const reply = await employerService.findAllUnvalidated(); - expect(reply[0].validated).toBeFalsy; + expect(reply[0].validated).toBeFalsy(); }); it('finds all validated employers', async () => { diff --git a/src/users/services/jobs.service.spec.ts b/src/users/services/jobs.service.spec.ts index 91cdb71d3c7be03f8c98c9e5311c87f1e6e6e750..363bd456caacf338cf3e54fcd4fd766f6e53241f 100644 --- a/src/users/services/jobs.service.spec.ts +++ b/src/users/services/jobs.service.spec.ts @@ -146,7 +146,7 @@ describe('JobsService', () => { }, ]); const reply = await jobsService.findAllUnvalidated(); - expect(reply[0].validated).toBeFalsy; + expect(reply[0].validated).toBeFalsy(); }); it('findByName', async () => { @@ -335,7 +335,7 @@ describe('JobsService', () => { const reply = await jobsService.deleteOneId('623aed68c5d45b6fbbaa7e60'); expect(reply).toBe('toto'); }); - it('should delete', async () => { + it('should not be able to delete', async () => { mockJobModel.exec.mockResolvedValueOnce(null); try { await jobsService.deleteOneId('623aed68c5d45b6fbbaa7e60'); diff --git a/src/users/services/users.service.spec.ts b/src/users/services/users.service.spec.ts index 13aee0af65d492f9c84d43867850d38fe4815da1..91c59ce93fe49bc50a1d026314fb74107beeebdf 100644 --- a/src/users/services/users.service.spec.ts +++ b/src/users/services/users.service.spec.ts @@ -222,9 +222,6 @@ describe('UsersService', () => { it('should return false with "azertyu1" (no special character)', () => { expect(usersService.isStrongPassword('azertyu1')).toBe(false); }); - it('should return false with "azertyu1" (no special character)', () => { - expect(usersService.isStrongPassword('azertyu1')).toBe(false); - }); it('should return false with "azer" (too short)', () => { expect(usersService.isStrongPassword('azer')).toBe(false); }); @@ -303,34 +300,6 @@ describe('UsersService', () => { }); }); - describe('changeUserPassword', () => { - // TODO implement correct tests - }); - - describe('changeUserEmail', () => { - // TODO implement correct tests - }); - - describe('sendResetPasswordEmail', () => { - // TODO implement correct tests - }); - - describe('validatePasswordResetToken', () => { - // TODO implement correct tests - }); - - it('should find All Unattacheduser', async () => { - return; - }); - - it('should find attached users', async () => { - return; - }); - - it('should find UnVerified Users', async () => { - return; - }); - describe('addPersonalOffer', () => { const personalOfferDocumentMock: PersonalOfferDocument = personalOffersDataMock[0] as PersonalOfferDocument; it('should add personal offer to the user', async () => { @@ -380,38 +349,6 @@ describe('UsersService', () => { await usersService.replaceEmployers(employersMockData[0], employersMockData[1]); expect(spyer).toHaveBeenCalledTimes(1); }); - - it('should return true if a user is linked to a given employer', async () => { - return; - }); - it('should fetch users attached to a given employer', async () => { - return; - }); - it('should populate an employer with a list of attached users', async () => { - return; - }); - it("should update user's employer", async () => { - return; - }); - }); - - describe('user job', () => { - it('should replace job with a new one', async () => { - return; - }); - - it('should return true if a user is linked to a given job', async () => { - return; - }); - it('should fetch users attached to a given job', async () => { - return; - }); - it('should populate an job with a list of attached users', async () => { - return; - }); - it("should update user's job", async () => { - return; - }); }); describe('updateUserProfile', () => { diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts deleted file mode 100644 index 0fd486aa705c1e66f995309e093f094453482e0c..0000000000000000000000000000000000000000 --- a/test/app.e2e-spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import * as request from 'supertest'; -import { Test } from '@nestjs/testing'; -import { AppModule } from './../src/app.module'; -import { INestApplication } from '@nestjs/common'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeAll(async () => { - const moduleFixture = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!'); - }); -});