File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -528,6 +528,20 @@ describe('FirebaseAuth', () => {
528528 expect ( app . auth ( ) . signOut ) . toHaveBeenCalled ( ) ;
529529 } ) ;
530530 } ) ;
531+
532+
533+ describe ( 'getAuth()' , ( ) => {
534+ it ( 'should return null when no user is logged in' , ( ) => {
535+ authSpy [ 'currentUser' ] = null ;
536+ expect ( afAuth . getAuth ( ) ) . toBe ( null ) ;
537+ } ) ;
538+
539+
540+ it ( 'should return authState if user is logged in' , ( ) => {
541+ authSpy [ 'currentUser' ] = firebaseUser ;
542+ expect ( afAuth . getAuth ( ) . uid ) . toEqual ( AngularFireAuthState . uid ) ;
543+ } )
544+ } ) ;
531545 } ) ;
532546} ) ;
533547
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export interface TwitterCredential extends CommonOAuthCredential {
7070export type OAuthCredential = CommonOAuthCredential | GoogleCredential | TwitterCredential ;
7171
7272export function authDataToAuthState ( authData : firebase . User , providerData ?: OAuthCredential ) : FirebaseAuthState {
73+ if ( ! authData ) return null ;
7374 let providerId ;
7475 let { uid } = authData ;
7576 let authState : FirebaseAuthState = { auth : authData , uid, provider : null } ;
You can’t perform that action at this time.
0 commit comments