@@ -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