Skip to content

Commit 2c62cf0

Browse files
committed
#1568 - fix tests
1 parent 9f09347 commit 2c62cf0

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/backend/tests/reimbursement-requests.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,21 @@ describe('Reimbursement Requests', () => {
143143
// assert
144144
expect(prismaFindTeamSpy).toBeCalledTimes(1);
145145
expect(prismaFindTeamSpy).toBeCalledWith({
146-
where: { teamId: process.env.FINANCE_TEAM_ID }
146+
where: { teamId: process.env.FINANCE_TEAM_ID },
147+
include: { head: true, leads: true, members: true }
147148
});
148149
});
149150

150-
test('fails if user is not head of finance team', async () => {
151+
test('fails if user is not on finance team', async () => {
151152
// mock prisma calls
152153
const prismaGetManySpy = vi.spyOn(prisma.reimbursement_Request, 'findMany').mockResolvedValue([findManyResult]);
153-
const prismaFindTeamSpy = vi.spyOn(prisma.team, 'findUnique').mockResolvedValue(prismaTeam1);
154+
vi.spyOn(prisma.team, 'findUnique').mockResolvedValue({ ...primsaTeam2, headId: 1 });
154155

155156
// act
156-
const action = async () => await ReimbursementRequestService.getPendingAdvisorList(batman);
157-
await expect(action).rejects.toEqual(new AccessDeniedException('You are not the head of the finance team!'));
157+
const action = async () => await ReimbursementRequestService.getPendingAdvisorList(alfred);
158+
await expect(action).rejects.toEqual(new AccessDeniedException(`You are not a member of the finance team!`));
158159

159160
// assert
160-
expect(prismaFindTeamSpy).toBeCalledTimes(1);
161-
expect(prismaFindTeamSpy).toBeCalledWith({
162-
where: { teamId: process.env.FINANCE_TEAM_ID }
163-
});
164161
expect(prismaGetManySpy).toBeCalledTimes(0);
165162
});
166163
});

0 commit comments

Comments
 (0)