@@ -88,24 +88,21 @@ describe('Parse.User testing', () => {
8888 await Parse . User . signUp ( 'existinguser' , 'password123' ) ;
8989 compareSpy . calls . reset ( ) ;
9090
91- // Login with non-existent user
92- try {
93- await Parse . User . logIn ( 'nonexistentuser' , 'wrongpassword' ) ;
94- } catch ( e ) {
95- expect ( e . code ) . toBe ( Parse . Error . OBJECT_NOT_FOUND ) ;
96- }
97- // bcrypt.compare should have been called even for non-existent user
91+ // Login with non-existent user — should use dummy hash
92+ await expectAsync (
93+ Parse . User . logIn ( 'nonexistentuser' , 'wrongpassword' )
94+ ) . toBeRejected ( ) ;
9895 expect ( compareSpy ) . toHaveBeenCalledTimes ( 1 ) ;
96+ expect ( compareSpy ) . toHaveBeenCalledWith ( 'wrongpassword' , passwordCrypto . dummyHash ) ;
9997 compareSpy . calls . reset ( ) ;
10098
101- // Login with existing user but wrong password
102- try {
103- await Parse . User . logIn ( 'existinguser' , 'wrongpassword' ) ;
104- } catch ( e ) {
105- expect ( e . code ) . toBe ( Parse . Error . OBJECT_NOT_FOUND ) ;
106- }
107- // bcrypt.compare should have been called for existing user
99+ // Login with existing user but wrong password — should use real hash
100+ await expectAsync (
101+ Parse . User . logIn ( 'existinguser' , 'wrongpassword' )
102+ ) . toBeRejected ( ) ;
108103 expect ( compareSpy ) . toHaveBeenCalledTimes ( 1 ) ;
104+ expect ( compareSpy . calls . mostRecent ( ) . args [ 0 ] ) . toBe ( 'wrongpassword' ) ;
105+ expect ( compareSpy . calls . mostRecent ( ) . args [ 1 ] ) . not . toBe ( passwordCrypto . dummyHash ) ;
109106 } ) ;
110107
111108 it ( 'logs username taken with configured log level' , async ( ) => {
0 commit comments