@@ -26,7 +26,7 @@ describe('FirebaseAuth',function(){
2626 [ 'authWithCustomToken' , 'authAnonymously' , 'authWithPassword' ,
2727 'authWithOAuthPopup' , 'authWithOAuthRedirect' , 'authWithOAuthToken' ,
2828 'unauth' , 'getAuth' , 'onAuth' , 'offAuth' ,
29- 'createUser' , 'changePassword' , 'removeUser' , 'resetPassword'
29+ 'createUser' , 'changePassword' , 'changeEmail' , ' removeUser', 'resetPassword'
3030 ] ) ;
3131
3232 inject ( function ( _$firebaseAuth_ , _$timeout_ ) {
@@ -196,7 +196,7 @@ describe('FirebaseAuth',function(){
196196 expect ( result ) . toEqual ( 'myResult' ) ;
197197 } ) ;
198198 } ) ;
199-
199+
200200 describe ( '$authWithOAuthToken' , function ( ) {
201201 it ( 'passes provider, token, and options object to underlying method' , function ( ) {
202202 var provider = 'facebook' ;
@@ -360,42 +360,95 @@ describe('FirebaseAuth',function(){
360360 expect ( result ) . toEqual ( { uid :'1234' } ) ;
361361 } ) ;
362362 } ) ;
363-
364- describe ( '$changePassword()' , function ( ) {
365- it ( 'passes email/password to method on backing ref (string args)' , function ( ) {
366- auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 367- expect ( ref . changePassword ) . toHaveBeenCalledWith (
368- { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } , 369- jasmine . any ( Function ) ) ;
370- } ) ;
371363
372- it ( 'passes email/password to method on backing ref (object arg)' , function ( ) {
373- auth . $changePassword ( { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } ) ; 374- expect ( ref . changePassword ) . toHaveBeenCalledWith (
375- { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } , 376- jasmine . any ( Function ) ) ;
377- } ) ;
378-
379- it ( 'will log a warning if deprecated string args are used' , function ( ) {
364+ describe ( '$changePassword()' , function ( ) {
365+ it ( 'passes credentials to method on backing ref (string args)' , function ( ) {
366+ auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 367+ expect ( ref . changePassword ) . toHaveBeenCalledWith ( {
368+ 369+ oldPassword : '54321' ,
370+ newPassword : '12345'
371+ } , jasmine . any ( Function ) ) ;
372+ } ) ;
373+
374+ it ( 'passes credentials to method on backing ref (object arg)' , function ( ) {
375+ auth . $changePassword ( {
376+ 377+ oldPassword : '54321' ,
378+ newPassword : '12345'
379+ } ) ;
380+ expect ( ref . changePassword ) . toHaveBeenCalledWith ( {
381+ 382+ oldPassword : '54321' ,
383+ newPassword : '12345'
384+ } , jasmine . any ( Function ) ) ;
385+ } ) ;
386+
387+ it ( 'will log a warning if deprecated string args are used' , function ( ) {
380388 auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ; 381389 expect ( log . warn ) . toHaveLength ( 1 ) ;
382390 } ) ;
383391
384- it ( 'will reject the promise if authentication fails' , function ( ) {
385- wrapPromise ( auth . $changePassword ( { email :
'[email protected] ' , oldPassword :
'54321' , newPassword :
'12345' } ) ) ; 392+ it ( 'will reject the promise if the password change fails' , function ( ) {
393+ wrapPromise ( auth . $changePassword ( {
394+ 395+ oldPassword : '54321' ,
396+ newPassword : '12345'
397+ } ) ) ;
386398 callback ( 'changePassword' ) ( "bad password" ) ;
387399 $timeout . flush ( ) ;
388400 expect ( failure ) . toEqual ( "bad password" ) ;
389401 } ) ;
390402
391- it ( 'will resolve the promise upon authentication' , function ( ) {
392- wrapPromise ( auth . $changePassword ( '[email protected] ' , '54321' , '12345' ) ) ; 403+ it ( 'will resolve the promise upon the password change' , function ( ) {
404+ wrapPromise ( auth . $changePassword ( {
405+ 406+ oldPassword : '54321' ,
407+ newPassword : '12345'
408+ } ) ) ;
393409 callback ( 'changePassword' ) ( null ) ;
394410 $timeout . flush ( ) ;
395411 expect ( status ) . toEqual ( 'resolved' ) ;
396412 } ) ;
397413 } ) ;
398-
414+
415+ describe ( '$changeEmail()' , function ( ) {
416+ it ( 'passes credentials to method on backing reference' , function ( ) {
417+ auth . $changeEmail ( {
418+ 419+ 420+ password : '12345'
421+ } ) ;
422+ expect ( ref . changeEmail ) . toHaveBeenCalledWith ( {
423+ 424+ 425+ password : '12345'
426+ } , jasmine . any ( Function ) ) ;
427+ } ) ;
428+
429+ it ( 'will reject the promise if the email change fails' , function ( ) {
430+ wrapPromise ( auth . $changeEmail ( {
431+ 432+ 433+ password : '12345'
434+ } ) ) ;
435+ callback ( 'changeEmail' ) ( "bad password" ) ;
436+ $timeout . flush ( ) ;
437+ expect ( failure ) . toEqual ( "bad password" ) ;
438+ } ) ;
439+
440+ it ( 'will resolve the promise upon the email change' , function ( ) {
441+ wrapPromise ( auth . $changeEmail ( {
442+ 443+ 444+ password : '12345'
445+ } ) ) ;
446+ callback ( 'changeEmail' ) ( null ) ;
447+ $timeout . flush ( ) ;
448+ expect ( status ) . toEqual ( 'resolved' ) ;
449+ } ) ;
450+ } ) ;
451+
399452 describe ( '$removeUser()' , function ( ) {
400453 it ( 'passes email/password to method on backing ref (string args)' , function ( ) {
401454 auth . $removeUser ( '[email protected] ' , '12345' ) ; @@ -430,7 +483,7 @@ describe('FirebaseAuth',function(){
430483 expect ( status ) . toEqual ( 'resolved' ) ;
431484 } ) ;
432485 } ) ;
433-
486+
434487 describe ( '$sendPasswordResetEmail()' , function ( ) {
435488 it ( 'passes email to method on backing ref (string args)' , function ( ) {
436489 auth . $sendPasswordResetEmail ( '[email protected] ' ) ; @@ -450,7 +503,7 @@ describe('FirebaseAuth',function(){
450503 auth . $sendPasswordResetEmail ( { email :
'[email protected] ' } ) ; 451504 expect ( log . warn ) . toHaveLength ( 1 ) ;
452505 } ) ;
453-
506+
454507 it ( 'will log two deprecation warnings if string arg is used' , function ( ) {
455508 auth . $sendPasswordResetEmail ( '[email protected] ' ) ; 456509 expect ( log . warn ) . toHaveLength ( 2 ) ;
@@ -470,7 +523,7 @@ describe('FirebaseAuth',function(){
470523 expect ( status ) . toEqual ( 'resolved' ) ;
471524 } ) ;
472525 } ) ;
473-
526+
474527 describe ( '$resetPassword()' , function ( ) {
475528 it ( 'passes email to method on backing ref (string args)' , function ( ) {
476529 auth . $resetPassword ( '[email protected] ' ) ;
0 commit comments