@@ -384,7 +384,57 @@ describe('FirebaseAuth',function(){
384384 tick ( ) ;
385385 } ) ;
386386 } ) ;
387+
388+ describe ( '$requireSignIn(requireEmailVerification)' , function ( ) {
389+ it ( 'will be resolved if user is logged in and has a verified email address' , function ( done ) {
390+ var credentials = { provider : 'facebook' , emailVerified : true } ;
391+ spyOn ( authService . _ , 'getAuth' ) . and . callFake ( function ( ) {
392+ return credentials ;
393+ } ) ;
394+
395+ authService . $requireSignIn ( true )
396+ . then ( function ( result ) {
397+ expect ( result ) . toEqual ( credentials ) ;
398+ done ( ) ;
399+ } ) ;
387400
401+ fakePromiseResolve ( credentials ) ;
402+ tick ( ) ;
403+ } ) ;
404+
405+ it ( 'will be resolved if user is logged in and we ignore email verification' , function ( done ) {
406+ var credentials = { provider : 'facebook' , emailVerified : false } ;
407+ spyOn ( authService . _ , 'getAuth' ) . and . callFake ( function ( ) {
408+ return credentials ;
409+ } ) ;
410+
411+ authService . $requireSignIn ( false )
412+ . then ( function ( result ) {
413+ expect ( result ) . toEqual ( credentials ) ;
414+ done ( ) ;
415+ } ) ;
416+
417+ fakePromiseResolve ( credentials ) ;
418+ tick ( ) ;
419+ } ) ;
420+
421+ it ( 'will be rejected if user does not have a verified email address' , function ( done ) {
422+ var credentials = { provider : 'facebook' , emailVerified : false } ;
423+ spyOn ( authService . _ , 'getAuth' ) . and . callFake ( function ( ) {
424+ return credentials ;
425+ } ) ;
426+
427+ authService . $requireSignIn ( true )
428+ . catch ( function ( error ) {
429+ expect ( error ) . toEqual ( 'EMAIL_VERIFICATION_REQUIRED' ) ;
430+ done ( ) ;
431+ } ) ;
432+
433+ fakePromiseResolve ( credentials ) ;
434+ tick ( ) ;
435+ } ) ;
436+ } ) ;
437+
388438 describe ( '$waitForSignIn()' , function ( ) {
389439 it ( 'will be resolved with authData if user is logged in' , function ( done ) {
390440 var credentials = { provider : 'facebook' } ;
0 commit comments