@@ -27,7 +27,7 @@ describe('FirebaseAuth',function(){
2727 [ 'authWithCustomToken' , 'authAnonymously' , 'authWithPassword' ,
2828 'authWithOAuthPopup' , 'authWithOAuthRedirect' , 'authWithOAuthToken' ,
2929 'unauth' , 'getAuth' , 'onAuth' , 'offAuth' ,
30- 'createUser' , 'changePassword' , 'removeUser' , 'resetPassword'
30+ 'createUser' , 'changePassword' , 'changeEmail' , ' removeUser', 'resetPassword'
3131 ] ) ;
3232
3333 inject ( function ( _$firebaseAuth_ , _$timeout_ ) {
@@ -197,7 +197,7 @@ describe('FirebaseAuth',function(){
197197 expect ( result ) . toEqual ( 'myResult' ) ;
198198 } ) ;
199199 } ) ;
200-
200+
201201 describe ( '$authWithOAuthToken' , function ( ) {
202202 it ( 'passes provider, token, and options object to underlying method' , function ( ) {
203203 var provider = 'facebook' ;
@@ -361,42 +361,95 @@ describe('FirebaseAuth',function(){
361361 expect ( result ) . toEqual ( { uid :'1234' } ) ;
362362 } ) ;
363363 } ) ;
364-
365- describe ( '$changePassword()' , function ( ) {
366- it ( 'passes email/password to method on backing ref (string args)' , function ( ) {
367- auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 368- expect ( ref . changePassword ) . toHaveBeenCalledWith (
369- { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } , 370- jasmine . any ( Function ) ) ;
371- } ) ;
372364
373- it ( 'passes email/password to method on backing ref (object arg)' , function ( ) {
374- auth . $changePassword ( { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } ) ; 375- expect ( ref . changePassword ) . toHaveBeenCalledWith (
376- { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } , 377- jasmine . any ( Function ) ) ;
378- } ) ;
379-
380- it ( 'will log a warning if deprecated string args are used' , function ( ) {
365+ describe ( '$changePassword()' , function ( ) {
366+ it ( 'passes credentials to method on backing ref (string args)' , function ( ) {
367+ auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 368+ expect ( ref . changePassword ) . toHaveBeenCalledWith ( {
369+ 370+ oldPassword : '54321' ,
371+ newPassword : '12345'
372+ } , jasmine . any ( Function ) ) ;
373+ } ) ;
374+
375+ it ( 'passes credentials to method on backing ref (object arg)' , function ( ) {
376+ auth . $changePassword ( {
377+ 378+ oldPassword : '54321' ,
379+ newPassword : '12345'
380+ } ) ;
381+ expect ( ref . changePassword ) . toHaveBeenCalledWith ( {
382+ 383+ oldPassword : '54321' ,
384+ newPassword : '12345'
385+ } , jasmine . any ( Function ) ) ;
386+ } ) ;
387+
388+ it ( 'will log a warning if deprecated string args are used' , function ( ) {
381389 auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 382390 expect ( log . warn ) . toHaveLength ( 1 ) ;
383391 } ) ;
384392
385- it ( 'will reject the promise if authentication fails' , function ( ) {
386- wrapPromise ( auth . $changePassword ( { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } ) ) ; 393+ it ( 'will reject the promise if authentication fails' , function ( ) {
394+ wrapPromise ( auth . $changePassword ( {
395+ 396+ oldPassword : '54321' ,
397+ newPassword : '12345'
398+ } ) ) ;
387399 callback ( 'changePassword' ) ( "bad password" ) ;
388400 $timeout . flush ( ) ;
389401 expect ( failure ) . toEqual ( "bad password" ) ;
390402 } ) ;
391403
392- it ( 'will resolve the promise upon authentication' , function ( ) {
393- wrapPromise ( auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ) ; 404+ it ( 'will resolve the promise upon authentication' , function ( ) {
405+ wrapPromise ( auth . $changePassword ( {
406+ 407+ oldPassword : '54321' ,
408+ newPassword : '12345'
409+ } ) ) ;
394410 callback ( 'changePassword' ) ( null ) ;
395411 $timeout . flush ( ) ;
396412 expect ( status ) . toEqual ( 'resolved' ) ;
397413 } ) ;
398414 } ) ;
399-
415+
416+ describe ( '$changeEmail()' , function ( ) {
417+ it ( 'passes credentials to method on backing reference' , function ( ) {
418+ auth . $changeEmail ( {
419+ 420+ 421+ password : '12345'
422+ } ) ;
423+ expect ( ref . changeEmail ) . toHaveBeenCalledWith ( {
424+ 425+ 426+ password : '12345'
427+ } , jasmine . any ( Function ) ) ;
428+ } ) ;
429+
430+ it ( 'will reject the promise if authentication fails' , function ( ) {
431+ wrapPromise ( auth . $changeEmail ( {
432+ 433+ 434+ password : '12345'
435+ } ) ) ;
436+ callback ( 'changeEmail' ) ( "bad password" ) ;
437+ $timeout . flush ( ) ;
438+ expect ( failure ) . toEqual ( "bad password" ) ;
439+ } ) ;
440+
441+ it ( 'will resolve the promise upon authentication' , function ( ) {
442+ wrapPromise ( auth . $changeEmail ( {
443+ 444+ 445+ password : '12345'
446+ } ) ) ;
447+ callback ( 'changeEmail' ) ( null ) ;
448+ $timeout . flush ( ) ;
449+ expect ( status ) . toEqual ( 'resolved' ) ;
450+ } ) ;
451+ } ) ;
452+
400453 describe ( '$removeUser()' , function ( ) {
401454 it ( 'passes email/password to method on backing ref (string args)' , function ( ) {
402455 auth . $removeUser ( '[email protected] ' , '12345' ) ; @@ -431,7 +484,7 @@ describe('FirebaseAuth',function(){
431484 expect ( status ) . toEqual ( 'resolved' ) ;
432485 } ) ;
433486 } ) ;
434-
487+
435488 describe ( '$sendPasswordResetEmail()' , function ( ) {
436489 it ( 'passes email to method on backing ref (string args)' , function ( ) {
437490 auth . $sendPasswordResetEmail ( '[email protected] ' ) ; @@ -451,7 +504,7 @@ describe('FirebaseAuth',function(){
451504 auth . $sendPasswordResetEmail ( { email :
'[email protected] ' } ) ; 452505 expect ( log . warn ) . toHaveLength ( 1 ) ;
453506 } ) ;
454-
507+
455508 it ( 'will log two deprecation warnings if string arg is used' , function ( ) {
456509 auth . $sendPasswordResetEmail ( '[email protected] ' ) ; 457510 expect ( log . warn ) . toHaveLength ( 2 ) ;
@@ -471,7 +524,7 @@ describe('FirebaseAuth',function(){
471524 expect ( status ) . toEqual ( 'resolved' ) ;
472525 } ) ;
473526 } ) ;
474-
527+
475528 describe ( '$resetPassword()' , function ( ) {
476529 it ( 'passes email to method on backing ref (string args)' , function ( ) {
477530 auth . $resetPassword ( '[email protected] ' ) ; @@ -506,4 +559,4 @@ describe('FirebaseAuth',function(){
506559 expect ( status ) . toEqual ( 'resolved' ) ;
507560 } ) ;
508561 } ) ;
509- } ) ;
562+ } ) ;
0 commit comments