@@ -789,24 +789,18 @@ describe('core/auth/auth_impl', () => {
789
789
790
790
describe ( 'AuthStateReady' , ( ) => {
791
791
let user : UserInternal ;
792
- let onAuthStateChangedCallback : sinon . SinonSpy ;
793
792
let authStateChangedSpy : sinon . SinonSpy ;
794
793
795
794
beforeEach ( async ( ) => {
796
795
user = testUser ( auth , 'uid' ) ;
797
796
798
- onAuthStateChangedCallback = sinon . spy ( ) ;
799
- auth . onAuthStateChanged ( onAuthStateChangedCallback ) ;
800
797
authStateChangedSpy = sinon . spy ( auth , 'onAuthStateChanged' ) ;
801
798
802
799
await auth . _updateCurrentUser ( null ) ;
803
800
} ) ;
804
801
805
- //case one: if(this.currentUser) is true --> resolves immediately
806
802
it ( 'immediately returns resolved promise if the user is previously logged in' , async ( ) => {
807
- expect ( onAuthStateChangedCallback ) . to . be . calledOnce ;
808
803
await auth . _updateCurrentUser ( user ) ;
809
- expect ( onAuthStateChangedCallback ) . to . be . calledTwice ;
810
804
811
805
await auth
812
806
. authStateReady ( )
@@ -817,11 +811,8 @@ describe('core/auth/auth_impl', () => {
817
811
. catch ( error => {
818
812
throw new Error ( error ) ;
819
813
} ) ;
820
-
821
- expect ( onAuthStateChangedCallback ) . to . be . calledTwice ;
822
814
} ) ;
823
815
824
- //case two: if(this.currentUser) is false --> calls onAuthStateChanged
825
816
it ( 'returns resolved promise once the user is initialized to object of type UserInternal' , async ( ) => {
826
817
expect ( authStateChangedSpy ) . to . not . have . been . called ;
827
818
const promiseVar = auth . authStateReady ( ) ;
@@ -831,19 +822,16 @@ describe('core/auth/auth_impl', () => {
831
822
832
823
await promiseVar
833
824
. then ( ( ) => {
834
- // onAuthStateChangedCallback();
835
825
expect ( auth . currentUser ) . to . eq ( user ) ;
836
826
} )
837
827
. catch ( error => {
838
828
throw new Error ( error ) ;
839
829
} ) ;
840
830
841
831
expect ( authStateChangedSpy ) . to . be . calledOnce ;
842
- // expect(onAuthStateChangedCallback).to.be.calledThrice;
843
832
} ) ;
844
833
845
- //case three: if user logged out more than once, promise should still be resolved with currentUser remained as null
846
- it ( 'resolves promise with currentUser remains as null when user logs out more than once' , async ( ) => {
834
+ it ( 'resolves the promise during repeated logout' , async ( ) => {
847
835
expect ( authStateChangedSpy ) . to . not . have . been . called ;
848
836
const promiseVar = auth . authStateReady ( ) ;
849
837
expect ( authStateChangedSpy ) . to . be . calledOnce ;
@@ -861,7 +849,6 @@ describe('core/auth/auth_impl', () => {
861
849
expect ( authStateChangedSpy ) . to . be . calledOnce ;
862
850
} ) ;
863
851
864
- //case four: user sign in failed, expect promise to resolve and allow currentUser to be null.
865
852
it ( 'resolves the promise with currentUser remain null during log in failure' , async ( ) => {
866
853
expect ( authStateChangedSpy ) . to . not . have . been . called ;
867
854
const promiseVar = auth . authStateReady ( ) ;
@@ -886,7 +873,6 @@ describe('core/auth/auth_impl', () => {
886
873
expect ( authStateChangedSpy ) . to . be . calledOnce ;
887
874
} ) ;
888
875
889
- //case five: user sign in delay, promise should be resolved after delay.
890
876
it ( 'resolves the promise in a delayed user log in process' , async ( ) => {
891
877
setTimeout ( async ( ) => {
892
878
await auth . _updateCurrentUser ( user ) ;
0 commit comments