@@ -6,8 +6,7 @@ import { Observer } from 'rxjs/Observer';
66import { TestBed , inject } from '@angular/core/testing' ;
77import { _do } from 'rxjs/operator/do' ;
88import { take } from 'rxjs/operator/take' ;
9- import 'rxjs/operator/take' ;
10- import 'rxjs/operator/do' ;
9+ import { skip } from 'rxjs/operator/skip' ;
1110import { FIREBASE_PROVIDERS , FirebaseApp , FirebaseAppConfig , FirebaseAuthState , FirebaseAppConfigToken , AngularFireAuth , AuthMethods , firebaseAuthConfig , AuthProviders , WindowLocation , AngularFireModule } from '../angularfire2' ;
1211import { COMMON_CONFIG , ANON_AUTH_CONFIG } from '../test-config' ;
1312import { AuthBackend } from './auth_backend' ;
@@ -73,6 +72,14 @@ const AngularFireAuthState = {
7372 } as firebase . UserInfo
7473} as FirebaseAuthState ;
7574
75+ function authTake ( auth : AngularFireAuth | Observable < any > , count : number ) : Observable < any > {
76+ return take . call ( auth , 1 ) ;
77+ }
78+
79+ function authSkip ( auth : AngularFireAuth , count : number ) : Observable < any > {
80+ return skip . call ( auth , 1 ) ;
81+ }
82+
7683describe ( 'Zones' , ( ) => {
7784 it ( 'should call operators and subscriber in the same zone as when service was initialized' , ( done ) => {
7885 // Initialize the app outside of the zone, to mimick real life behavior.
@@ -83,7 +90,7 @@ describe('Zones', () => {
8390 } ) ;
8491 ngZone . run ( ( ) => {
8592 var afAuth = new AngularFireAuth ( new FirebaseSdkAuthBackend ( app ) , window . location ) ;
86- var authObs = afAuth . take ( 1 ) ;
93+ var authObs = authTake ( afAuth , 1 ) ;
8794
8895 _do . call ( authObs , _ => {
8996 expect ( Zone . current . name ) . toBe ( 'ngZone' ) ;
@@ -176,18 +183,16 @@ describe('FirebaseAuth', () => {
176183 fbAuthObserver . next ( null ) ;
177184
178185 // Check that the first value is null
179- afAuth
180- . take ( 1 )
186+ take . call ( afAuth , 1 )
181187 . do ( ( authData ) => {
182188 expect ( authData ) . toBe ( null ) ;
183189 setTimeout ( ( ) => fbAuthObserver . next ( firebaseUser ) ) ;
184190 } )
185191 . subscribe ( ) ;
186192
187193 // Check the 2nd value emitted from the observable
188- afAuth
189- . skip ( 1 )
190- . take ( 1 )
194+ const skipObs = authSkip ( afAuth , 1 ) ;
195+ take . call ( skipObs , 1 )
191196 . do ( ( authData ) => {
192197 expect ( authData . auth ) . toEqual ( AngularFireAuthState . auth ) ;
193198 } )
@@ -198,17 +203,15 @@ describe('FirebaseAuth', () => {
198203 describe ( 'AuthState' , ( ) => {
199204 it ( 'should asynchronously load firebase auth data' , ( done ) => {
200205 fbAuthObserver . next ( firebaseUser ) ;
201- afAuth
202- . take ( 1 )
206+ authTake ( afAuth , 1 )
203207 . subscribe ( ( data ) => {
204208 expect ( data . auth ) . toEqual ( AngularFireAuthState . auth ) ;
205209 } , done . fail , done ) ;
206210 } ) ;
207211
208212 it ( 'should be null if user is not authed' , ( done ) => {
209213 fbAuthObserver . next ( null ) ;
210- afAuth
211- . take ( 1 )
214+ authTake ( afAuth , 1 )
212215 . subscribe ( authData => {
213216 expect ( authData ) . toBe ( null ) ;
214217 } , done . fail , done ) ;
@@ -443,8 +446,7 @@ describe('FirebaseAuth', () => {
443446 } ) ;
444447
445448 it ( 'should include credentials in onAuth payload after logging in' , ( done ) => {
446- afAuth
447- . take ( 1 )
449+ take . call ( afAuth , 1 )
448450 . do ( ( user : FirebaseAuthState ) => {
449451 expect ( user . github ) . toBe ( githubCredential . credential ) ;
450452 } )
@@ -460,8 +462,7 @@ describe('FirebaseAuth', () => {
460462
461463 xit ( 'should not call getRedirectResult() if location.protocol is not http or https' , ( done ) => {
462464 windowLocation . protocol = 'file:' ;
463- afAuth
464- . take ( 1 )
465+ take . call ( afAuth , 1 )
465466 . do ( ( ) => {
466467 expect ( authSpy [ 'getRedirectResult' ] ) . not . toHaveBeenCalled ( ) ;
467468 } )
@@ -500,8 +501,7 @@ describe('FirebaseAuth', () => {
500501
501502 it ( 'should include credentials in onAuth payload after logging in' , ( done ) => {
502503 authSpy [ 'getRedirectResult' ] . and . returnValue ( Promise . resolve ( githubCredential ) ) ;
503- afAuth
504- . do ( ( user : FirebaseAuthState ) => {
504+ _do . call ( afAuth , ( user : FirebaseAuthState ) => {
505505 expect ( user . github ) . toBe ( githubCredential . credential ) ;
506506 } )
507507 . take ( 2 )
0 commit comments