File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,4 +186,52 @@ describe('Member Controller - updateAMember', () => {
186186 user : updatedMember ,
187187 } ) ;
188188 } ) ;
189+
190+ it ( 'should update password when password is provided in memberData' , async ( ) => {
191+ const req = {
192+ params : { memberId : 'abc-123' } ,
193+ body : { memberData : JSON . stringify ( { password : 'newSecurePass123' } ) } ,
194+ file : undefined ,
195+ } as unknown as Request ;
196+
197+ const res = mockResponse ( ) ;
198+
199+ const updatedMember = {
200+ id : '123' ,
201+ name : 'Updated User' ,
202+ email : 'updated@example.com' ,
203+ profilePhoto : null ,
204+ github : null ,
205+ phone : null ,
206+ bio : null ,
207+ linkedin : null ,
208+ twitter : null ,
209+ leetcode : null ,
210+ codeforces : null ,
211+ codechef : null ,
212+ gfg : null ,
213+ geeksforgeeks : null ,
214+ passoutYear : new Date ( '2025-05-31' ) ,
215+ isManager : false ,
216+ isApproved : false ,
217+ approvedById : null ,
218+ createdAt : new Date ( ) ,
219+ updatedAt : new Date ( ) ,
220+ } ;
221+
222+ // Mock updatePassword and getDetails
223+ jest . spyOn ( memberService , 'updatePassword' ) . mockResolvedValue ( { } as any ) ;
224+ jest . spyOn ( memberService , 'getDetails' ) . mockResolvedValue ( updatedMember ) ;
225+
226+ const handler = updateAMember ( mockSupabase ) ;
227+ await handler ( req , res ) ;
228+
229+ expect ( memberService . updatePassword ) . toHaveBeenCalledWith ( 'abc-123' , 'newSecurePass123' ) ;
230+ expect ( memberService . getDetails ) . toHaveBeenCalledTimes ( 1 ) ;
231+ expect ( res . status ) . toHaveBeenCalledWith ( 200 ) ;
232+ expect ( res . json ) . toHaveBeenCalledWith ( {
233+ success : true ,
234+ user : updatedMember ,
235+ } ) ;
236+ } ) ;
189237} ) ;
You can’t perform that action at this time.
0 commit comments