@@ -326,6 +326,53 @@ describe('ParseUser', () => {
326326      } ) ; 
327327  } ) ; 
328328
329+   describe ( 'loginWithAdditional' ,  ( )  =>  { 
330+     it ( 'loginWithAdditonal fails with invalid payload' ,  async  ( )  =>  { 
331+       ParseUser . enableUnsafeCurrentUser ( ) ; 
332+       ParseUser . _clearCache ( ) ; 
333+       CoreManager . setRESTController ( { 
334+         request ( method ,  path ,  body )  { 
335+           expect ( method ) . toBe ( 'POST' ) ; 
336+           expect ( path ) . toBe ( 'login' ) ; 
337+           expect ( body . username ) . toBe ( 'username' ) ; 
338+           expect ( body . password ) . toBe ( 'password' ) ; 
339+           expect ( body . authData ) . toEqual ( {  mfa : {  key : '1234'  }  } ) ; 
340+ 
341+           return  Promise . resolve ( 
342+             { 
343+               objectId : 'uid2' , 
344+               username : 'username' , 
345+               sessionToken : '123abc' , 
346+               authDataResponse : { 
347+                 mfa : {  enabled : true  } , 
348+               } , 
349+             } , 
350+             200 
351+           ) ; 
352+         } , 
353+         ajax ( )  { } , 
354+       } ) ; 
355+       const  response  =  await  ParseUser . logInWithAdditionalAuth ( 'username' ,  'password' ,  { mfa : { key :'1234' } } ) ; 
356+       expect ( response  instanceof  ParseUser ) . toBe ( true ) ; 
357+       expect ( response . get ( 'authDataResponse' ) ) . toEqual ( { mfa : {  enabled : true  } } ) ; 
358+     } ) ; 
359+ 
360+     it ( 'loginWithAdditonal fails with invalid payload' ,  async  ( )  =>  { 
361+       ParseUser . enableUnsafeCurrentUser ( ) ; 
362+       ParseUser . _clearCache ( ) ; 
363+       await  expect ( ParseUser . logInWithAdditionalAuth ( { } ,  'password' ,  { } ) ) . rejects . toThrowError ( 
364+         new  ParseError ( ParseError . OTHER_CAUSE ,  'Username must be a string.' ) 
365+       ) ; 
366+       await  expect ( ParseUser . logInWithAdditionalAuth ( 'username' ,  { } ,  { } ) ) . rejects . toThrowError ( 
367+         new  ParseError ( ParseError . OTHER_CAUSE ,  'Password must be a string.' ) 
368+       ) ; 
369+       await  expect ( ParseUser . logInWithAdditionalAuth ( 'username' ,  'password' ,  '' ) ) . rejects . toThrowError ( 
370+         new  ParseError ( ParseError . OTHER_CAUSE ,  'Auth must be an object.' ) 
371+       ) ; 
372+     } ) ; 
373+   } ) ; 
374+ 
375+ 
329376  it ( 'preserves changes when logging in' ,  done  =>  { 
330377    ParseUser . enableUnsafeCurrentUser ( ) ; 
331378    ParseUser . _clearCache ( ) ; 
0 commit comments