Skip to content

Commit

Permalink
fix: adjustments about array of recruitment session
Browse files Browse the repository at this point in the history
  • Loading branch information
whiitex committed Mar 12, 2024
1 parent 1c53702 commit 79d7705
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions api/src/recruitment-session/recruitment-session.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('RecruitmentSessionController', () => {
});
jest
.spyOn(service, 'findActiveRecruitmentSession')
.mockResolvedValue(mockRecruitmentSession);
.mockResolvedValue([mockRecruitmentSession]);
const result = await controller.findActive(mockAbility);
const expectedApp = {
...mockRecruitmentSession,
Expand All @@ -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);
Expand Down Expand Up @@ -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,
);
Expand All @@ -121,7 +121,7 @@ describe('RecruitmentSessionController', () => {
} as RecruitmentSessionResponseDto;
jest
.spyOn(service, 'findRecruitmentSessionById')
.mockResolvedValue(mockRecruitmentSession);
.mockResolvedValue([mockRecruitmentSession]);
jest
.spyOn(service, 'updateRecruitmentSession')
.mockResolvedValue(mockUpdatedRecruitmentSession);
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('RecruitmentSessionController', () => {
});
jest
.spyOn(service, 'findRecruitmentSessionById')
.mockResolvedValue(mockRecruitmentSession);
.mockResolvedValue([mockRecruitmentSession]);
const result = controller.updateRecruitmentSession(
mockRecruitmentSession.id,
mockUpdateRecruitmentSessionDto,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -263,7 +263,7 @@ describe('RecruitmentSessionController', () => {
} as UpdateRecruitmentSessionDto;
jest
.spyOn(service, 'findRecruitmentSessionById')
.mockResolvedValue(mockRecruitmentSessionToUpdate);
.mockResolvedValue([mockRecruitmentSessionToUpdate]);
jest
.spyOn(service, 'sessionHasPendingInterviews')
.mockResolvedValue(true);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
);
});
Expand All @@ -334,7 +334,7 @@ describe('RecruitmentSessionController', () => {
} as RecruitmentSession;
jest
.spyOn(service, 'findRecruitmentSessionById')
.mockResolvedValue(mockRecruitmentSessionToDelete);
.mockResolvedValue([mockRecruitmentSessionToDelete]);
jest
.spyOn(service, 'sessionHasPendingInterviews')
.mockResolvedValue(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 79d7705

Please sign in to comment.