@@ -64,6 +64,7 @@ function mockServiceFactory(app: FirebaseApp): FirebaseServiceInterface {
6464
6565describe ( 'FirebaseApp' , ( ) => {
6666 let mockApp : FirebaseApp ;
67+ let clock : sinon . SinonFakeTimers ;
6768 let getTokenStub : sinon . SinonStub ;
6869 let firebaseNamespace : FirebaseNamespace ;
6970 let firebaseNamespaceInternals : FirebaseNamespaceInternals ;
@@ -75,7 +76,7 @@ describe('FirebaseApp', () => {
7576 expires_in : 3600 ,
7677 } ) ;
7778
78- this . clock = sinon . useFakeTimers ( 1000 ) ;
79+ clock = sinon . useFakeTimers ( 1000 ) ;
7980
8081 mockApp = mocks . app ( ) ;
8182
@@ -90,7 +91,7 @@ describe('FirebaseApp', () => {
9091
9192 afterEach ( ( ) => {
9293 getTokenStub . restore ( ) ;
93- this . clock . restore ( ) ;
94+ clock . restore ( ) ;
9495 if ( firebaseConfigVar ) {
9596 process . env [ FIREBASE_CONFIG_VAR ] = firebaseConfigVar ;
9697 } else {
@@ -675,7 +676,7 @@ describe('FirebaseApp', () => {
675676
676677 it ( 'returns the cached token given no arguments' , ( ) => {
677678 return mockApp . INTERNAL . getToken ( true ) . then ( ( token1 ) => {
678- this . clock . tick ( 1000 ) ;
679+ clock . tick ( 1000 ) ;
679680 return mockApp . INTERNAL . getToken ( ) . then ( ( token2 ) => {
680681 expect ( token1 ) . to . deep . equal ( token2 ) ;
681682 expect ( getTokenStub ) . to . have . been . calledOnce ;
@@ -685,7 +686,7 @@ describe('FirebaseApp', () => {
685686
686687 it ( 'returns a new token with force refresh' , ( ) => {
687688 return mockApp . INTERNAL . getToken ( true ) . then ( ( token1 ) => {
688- this . clock . tick ( 1000 ) ;
689+ clock . tick ( 1000 ) ;
689690 return mockApp . INTERNAL . getToken ( true ) . then ( ( token2 ) => {
690691 expect ( token1 ) . to . not . deep . equal ( token2 ) ;
691692 expect ( getTokenStub ) . to . have . been . calledTwice ;
@@ -698,15 +699,15 @@ describe('FirebaseApp', () => {
698699 return mockApp . INTERNAL . getToken ( true ) . then ( ( token1 ) => {
699700 // Forward the clock to five minutes and one second before expiry.
700701 const expiryInMilliseconds = token1 . expirationTime - Date . now ( ) ;
701- this . clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) - 1000 ) ;
702+ clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) - 1000 ) ;
702703
703704 return mockApp . INTERNAL . getToken ( ) . then ( ( token2 ) => {
704705 // Ensure the token has not been proactively refreshed.
705706 expect ( token1 ) . to . deep . equal ( token2 ) ;
706707 expect ( getTokenStub ) . to . have . been . calledOnce ;
707708
708709 // Forward the clock to exactly five minutes before expiry.
709- this . clock . tick ( 1000 ) ;
710+ clock . tick ( 1000 ) ;
710711
711712 return mockApp . INTERNAL . getToken ( ) . then ( ( token3 ) => {
712713 // Ensure the token was proactively refreshed.
@@ -727,10 +728,10 @@ describe('FirebaseApp', () => {
727728
728729 // Forward the clock to exactly five minutes before expiry.
729730 const expiryInMilliseconds = token1 . expirationTime - Date . now ( ) ;
730- this . clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
731+ clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
731732
732733 // Forward the clock to exactly four minutes before expiry.
733- this . clock . tick ( 60 * 1000 ) ;
734+ clock . tick ( 60 * 1000 ) ;
734735
735736 // Restore the stubbed getAccessToken() method.
736737 getTokenStub . restore ( ) ;
@@ -745,7 +746,7 @@ describe('FirebaseApp', () => {
745746 expect ( getTokenStub ) . to . have . not . been . called ;
746747
747748 // Forward the clock to exactly three minutes before expiry.
748- this . clock . tick ( 60 * 1000 ) ;
749+ clock . tick ( 60 * 1000 ) ;
749750
750751 return mockApp . INTERNAL . getToken ( ) . then ( ( token3 ) => {
751752 // Ensure the token was proactively refreshed.
@@ -772,7 +773,7 @@ describe('FirebaseApp', () => {
772773
773774 // Forward the clock to exactly five minutes before expiry.
774775 const expiryInMilliseconds = token . expirationTime - Date . now ( ) ;
775- this . clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
776+ clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
776777
777778 // Due to synchronous timing issues when the timer is mocked, make a call to getToken()
778779 // without forcing a refresh to ensure there is enough time for the underlying token refresh
@@ -786,7 +787,7 @@ describe('FirebaseApp', () => {
786787 expect ( token ) . to . deep . equal ( originalToken ) ;
787788
788789 // Forward the clock to four minutes before expiry.
789- this . clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
790+ clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
790791
791792 // See note above about calling getToken().
792793 return mockApp . INTERNAL . getToken ( ) ;
@@ -798,7 +799,7 @@ describe('FirebaseApp', () => {
798799 expect ( token ) . to . deep . equal ( originalToken ) ;
799800
800801 // Forward the clock to three minutes before expiry.
801- this . clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
802+ clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
802803
803804 // See note above about calling getToken().
804805 return mockApp . INTERNAL . getToken ( ) ;
@@ -810,7 +811,7 @@ describe('FirebaseApp', () => {
810811 expect ( token ) . to . deep . equal ( originalToken ) ;
811812
812813 // Forward the clock to two minutes before expiry.
813- this . clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
814+ clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
814815
815816 // See note above about calling getToken().
816817 return mockApp . INTERNAL . getToken ( ) ;
@@ -822,7 +823,7 @@ describe('FirebaseApp', () => {
822823 expect ( token ) . to . deep . equal ( originalToken ) ;
823824
824825 // Forward the clock to one minute before expiry.
825- this . clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
826+ clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
826827
827828 // See note above about calling getToken().
828829 return mockApp . INTERNAL . getToken ( ) ;
@@ -834,7 +835,7 @@ describe('FirebaseApp', () => {
834835 expect ( token ) . to . deep . equal ( originalToken ) ;
835836
836837 // Forward the clock to expiry.
837- this . clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
838+ clock . tick ( ONE_MINUTE_IN_MILLISECONDS ) ;
838839
839840 // See note above about calling getToken().
840841 return mockApp . INTERNAL . getToken ( ) ;
@@ -852,7 +853,7 @@ describe('FirebaseApp', () => {
852853 return mockApp . INTERNAL . getToken ( true ) . then ( ( token1 ) => {
853854 // Forward the clock to five minutes and one second before expiry.
854855 let expiryInMilliseconds = token1 . expirationTime - Date . now ( ) ;
855- this . clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) - 1000 ) ;
856+ clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) - 1000 ) ;
856857
857858 // Force a token refresh.
858859 return mockApp . INTERNAL . getToken ( true ) . then ( ( token2 ) => {
@@ -861,7 +862,7 @@ describe('FirebaseApp', () => {
861862 expect ( getTokenStub ) . to . have . been . calledTwice ;
862863
863864 // Forward the clock to exactly five minutes before the original token's expiry.
864- this . clock . tick ( 1000 ) ;
865+ clock . tick ( 1000 ) ;
865866
866867 return mockApp . INTERNAL . getToken ( ) . then ( ( token3 ) => {
867868 // Ensure the token hasn't changed, meaning the proactive refresh was canceled.
@@ -870,7 +871,7 @@ describe('FirebaseApp', () => {
870871
871872 // Forward the clock to exactly five minutes before the refreshed token's expiry.
872873 expiryInMilliseconds = token3 . expirationTime - Date . now ( ) ;
873- this . clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
874+ clock . tick ( expiryInMilliseconds - ( 5 * ONE_MINUTE_IN_MILLISECONDS ) ) ;
874875
875876 return mockApp . INTERNAL . getToken ( ) . then ( ( token4 ) => {
876877 // Ensure the token was proactively refreshed.
@@ -896,11 +897,11 @@ describe('FirebaseApp', () => {
896897 return mockApp . INTERNAL . getToken ( true ) . then ( ( token1 ) => {
897898
898899 // Move the clock forward to three minutes and one second before expiry.
899- this . clock . tick ( 9 * 1000 ) ;
900+ clock . tick ( 9 * 1000 ) ;
900901 expect ( getTokenStub . callCount ) . to . equal ( 1 ) ;
901902
902903 // Move the clock forward to exactly three minutes before expiry.
903- this . clock . tick ( 1000 ) ;
904+ clock . tick ( 1000 ) ;
904905
905906 // Expect the underlying getAccessToken() method to have been called once.
906907 expect ( getTokenStub . callCount ) . to . equal ( 2 ) ;
@@ -974,7 +975,7 @@ describe('FirebaseApp', () => {
974975 return mockApp . INTERNAL . getToken ( ) . then ( ( token : FirebaseAccessToken ) => {
975976 expect ( addAuthTokenListenerSpy ) . to . have . been . calledOnce . and . calledWith ( token . accessToken ) ;
976977
977- this . clock . tick ( 1000 ) ;
978+ clock . tick ( 1000 ) ;
978979
979980 return mockApp . INTERNAL . getToken ( true ) ;
980981 } ) . then ( ( token : FirebaseAccessToken ) => {
@@ -1016,7 +1017,7 @@ describe('FirebaseApp', () => {
10161017
10171018 mockApp . INTERNAL . removeAuthTokenListener ( addAuthTokenListenerSpies [ 0 ] ) ;
10181019
1019- this . clock . tick ( 1000 ) ;
1020+ clock . tick ( 1000 ) ;
10201021
10211022 return mockApp . INTERNAL . getToken ( true ) ;
10221023 } ) . then ( ( token : FirebaseAccessToken ) => {
0 commit comments