diff --git a/api/src/recruitment-session/recruitment-session.controller.spec.ts b/api/src/recruitment-session/recruitment-session.controller.spec.ts index 719202d..abfa32a 100644 --- a/api/src/recruitment-session/recruitment-session.controller.spec.ts +++ b/api/src/recruitment-session/recruitment-session.controller.spec.ts @@ -51,7 +51,7 @@ describe('RecruitmentSessionController', () => { }); jest .spyOn(service, 'findActiveRecruitmentSession') - .mockResolvedValue(mockRecruitmentSession); + .mockResolvedValue([mockRecruitmentSession]); const result = await controller.findActive(mockAbility); const expectedApp = { ...mockRecruitmentSession, @@ -67,7 +67,7 @@ describe('RecruitmentSessionController', () => { }); jest .spyOn(service, 'findActiveRecruitmentSession') - .mockResolvedValue({ ...mockRecruitmentSession }); + .mockResolvedValue([mockRecruitmentSession]); const result = controller.findActive(mockAbility); await expect(result).rejects.toThrow(ForbiddenException); expect(service.findActiveRecruitmentSession).toHaveBeenCalledTimes(1); @@ -96,7 +96,7 @@ describe('RecruitmentSessionController', () => { it('should throw a ConflictException if there is already an active recruitment session', async () => { jest .spyOn(service, 'findActiveRecruitmentSession') - .mockResolvedValue(mockRecruitmentSession); + .mockResolvedValue([mockRecruitmentSession]); const result = controller.createRecruitmentSession( mockCreateRecruitmentSessionDto, ); @@ -121,7 +121,7 @@ describe('RecruitmentSessionController', () => { } as RecruitmentSessionResponseDto; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSession); + .mockResolvedValue([mockRecruitmentSession]); jest .spyOn(service, 'updateRecruitmentSession') .mockResolvedValue(mockUpdatedRecruitmentSession); @@ -165,7 +165,7 @@ describe('RecruitmentSessionController', () => { }); jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSession); + .mockResolvedValue([mockRecruitmentSession]); const result = controller.updateRecruitmentSession( mockRecruitmentSession.id, mockUpdateRecruitmentSessionDto, @@ -197,10 +197,10 @@ describe('RecruitmentSessionController', () => { } as UpdateRecruitmentSessionDto; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSessionToUpdate); + .mockResolvedValue([mockRecruitmentSessionToUpdate]); jest .spyOn(service, 'findActiveRecruitmentSession') - .mockResolvedValue(activeRecruitmentSession); + .mockResolvedValue([activeRecruitmentSession]); const result = controller.updateRecruitmentSession( mockRecruitmentSessionToUpdate.id, updateRecruitmentSessionDto, @@ -233,10 +233,10 @@ describe('RecruitmentSessionController', () => { } as UpdateRecruitmentSessionDto; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSessionToUpdate); + .mockResolvedValue([mockRecruitmentSessionToUpdate]); jest .spyOn(service, 'findActiveRecruitmentSession') - .mockResolvedValue(activeRecruitmentSession); + .mockResolvedValue([activeRecruitmentSession]); const result = controller.updateRecruitmentSession( mockRecruitmentSessionToUpdate.id, updateRecruitmentSessionDto, @@ -263,7 +263,7 @@ describe('RecruitmentSessionController', () => { } as UpdateRecruitmentSessionDto; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSessionToUpdate); + .mockResolvedValue([mockRecruitmentSessionToUpdate]); jest .spyOn(service, 'sessionHasPendingInterviews') .mockResolvedValue(true); @@ -296,9 +296,9 @@ describe('RecruitmentSessionController', () => { } as RecruitmentSessionResponseDto; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSession); + .mockResolvedValue([mockRecruitmentSession]); jest - .spyOn(service, 'deletRecruitmentSession') + .spyOn(service, 'deleteRecruitmentSession') .mockResolvedValue(mockDeletedRecruitmentSession); const result = await controller.deleteRecruitmentSession( mockRecruitmentSession.id, @@ -308,8 +308,8 @@ describe('RecruitmentSessionController', () => { expect(service.findRecruitmentSessionById).toHaveBeenCalledWith( mockRecruitmentSession.id, ); - expect(service.deletRecruitmentSession).toHaveBeenCalledTimes(1); - expect(service.deletRecruitmentSession).toHaveBeenCalledWith( + expect(service.deleteRecruitmentSession).toHaveBeenCalledTimes(1); + expect(service.deleteRecruitmentSession).toHaveBeenCalledWith( mockRecruitmentSession, ); }); @@ -334,7 +334,7 @@ describe('RecruitmentSessionController', () => { } as RecruitmentSession; jest .spyOn(service, 'findRecruitmentSessionById') - .mockResolvedValue(mockRecruitmentSessionToDelete); + .mockResolvedValue([mockRecruitmentSessionToDelete]); jest .spyOn(service, 'sessionHasPendingInterviews') .mockResolvedValue(true); diff --git a/api/src/recruitment-session/recruitment-session.service.spec.ts b/api/src/recruitment-session/recruitment-session.service.spec.ts index 04ce9a0..5c6e9fc 100644 --- a/api/src/recruitment-session/recruitment-session.service.spec.ts +++ b/api/src/recruitment-session/recruitment-session.service.spec.ts @@ -55,7 +55,7 @@ describe('Recruitment Session Service', () => { }); describe('findById', () => { - it('should return an application by id', async () => { + it('should return a recruitment session by id', async () => { const recruitmentSessionID = 1; jest .spyOn(mockedRepository, 'findBy') @@ -64,7 +64,7 @@ describe('Recruitment Session Service', () => { recruitmentSessionID, ); - expect(result).toEqual(mockRecruitmentSession); + expect(result[0]).toEqual(mockRecruitmentSession); expect(mockedRepository.findBy).toHaveBeenCalledTimes(1); expect(mockedRepository.findBy).toHaveBeenLastCalledWith({ id: recruitmentSessionID, @@ -78,7 +78,7 @@ describe('Recruitment Session Service', () => { recruitmentSessionID, ); - expect(result).toBeNull(); + expect(result).toEqual([]); expect(mockedRepository.findBy).toHaveBeenCalledTimes(1); expect(mockedRepository.findBy).toHaveBeenLastCalledWith({ id: recruitmentSessionID, @@ -96,7 +96,7 @@ describe('Recruitment Session Service', () => { const result = await recruitmentSessionService.findActiveRecruitmentSession(); - expect(result).toEqual(mockRecruitmentSession); + expect(result).toEqual([mockRecruitmentSession]); expect(mockedRepository.findBy).toHaveBeenCalledTimes(1); expect(mockedRepository.findBy).toHaveBeenCalledWith({ state: activeState,