@@ -24,16 +24,16 @@ import * as utils from '../utils';
2424import  {  Query ,  AFUnwrappedDataSnapshot  }  from  '../interfaces' ; 
2525import  {  Subscription ,  Observable ,  Subject  }  from  'rxjs' ; 
2626import  {  COMMON_CONFIG ,  ANON_AUTH_CONFIG  }  from  '../test-config' ; 
27- import  'rxjs/add/operator/do' ; 
28- import  'rxjs/add/operator/skip' ; 
29- import  'rxjs/add/operator/take' ; 
27+ import  {  _do  }  from  'rxjs/operator/do' ; 
28+ import  {  skip  }  from  'rxjs/operator/skip' ; 
29+ import  {  take  }  from  'rxjs/operator/take' ; 
30+ import  {  toPromise  }  from  'rxjs/operator/toPromise' ; 
3031
3132const  rootDatabaseUrl  =  COMMON_CONFIG . databaseURL ; 
3233
3334function  queryTest ( observable : Observable < any > ,  subject : Subject < any > ,  done : any )  { 
3435  let  nexted  =  false ; 
35-   observable 
36-     . take ( 2 ) 
36+   skipAndTake ( observable ,  2 ) 
3737    . subscribe ( val  =>  { 
3838      if  ( ! nexted )  { 
3939        subject . next ( '2' ) ; 
@@ -378,7 +378,7 @@ describe('FirebaseListFactory', () => {
378378
379379    it ( 'should emit only when the initial data set has been loaded' ,  ( done : any )  =>  { 
380380      ( < any > questions ) . _ref . set ( [ {  initial1 : true  } ,  {  initial2 : true  } ,  {  initial3 : true  } ,  {  initial4 : true  } ] ) 
381-         . then ( ( )  =>  questions . take ( 1 ) . toPromise ( ) ) 
381+         . then ( ( )  =>  toPromise . call ( skipAndTake ( questions ,   1 ) ) ) 
382382        . then ( ( val : any [ ] )  =>  { 
383383          expect ( val . length ) . toBe ( 4 ) ; 
384384        } ) 
@@ -389,10 +389,8 @@ describe('FirebaseListFactory', () => {
389389
390390
391391    it ( 'should emit a new value when a child moves' ,  ( done : any )  =>  { 
392-       subscription  =  questions 
393-         . skip ( 2 ) 
394-         . take ( 1 ) 
395-         . do ( ( data : any )  =>  { 
392+        let  question  =  skipAndTake ( questions ,  1 ,  2 ) 
393+        subscription  =  _do . call ( question ,  ( data : any )  =>  { 
396394          expect ( data . length ) . toBe ( 2 ) ; 
397395          expect ( data [ 0 ] . push2 ) . toBe ( true ) ; 
398396          expect ( data [ 1 ] . push1 ) . toBe ( true ) ; 
@@ -412,30 +410,26 @@ describe('FirebaseListFactory', () => {
412410    it ( 'should emit unwrapped data by default' ,  ( done : any )  =>  { 
413411      ref . remove ( ( )  =>  { 
414412        ref . push ( {  unwrapped : true  } ,  ( )  =>  { 
415-           subscription  =  questions 
416-             . take ( 1 ) 
417-             . do ( ( data : any )  =>  { 
418-               expect ( data . length ) . toBe ( 1 ) ; 
419-               expect ( data [ 0 ] . unwrapped ) . toBe ( true ) ; 
420-             } ) 
421-             . subscribe ( ( )  =>  { 
422-               done ( ) ; 
423-             } ,  done . fail ) ; 
413+           subscription  =  _do . call ( skipAndTake ( questions ,  1 ) ,  ( data : any )  =>  { 
414+             expect ( data . length ) . toBe ( 1 ) ; 
415+             expect ( data [ 0 ] . unwrapped ) . toBe ( true ) ; 
416+           } ) 
417+           . subscribe ( ( )  =>  { 
418+             done ( ) ; 
419+           } ,  done . fail ) ; 
424420        } ) ; 
425421      } ) ; 
426422    } ) ; 
427423
428424
429425    it ( 'should emit snapshots if preserveSnapshot option is true' ,  ( done : any )  =>  { 
430426      refSnapshotted . push ( 'hello snapshot!' ,  ( )  =>  { 
431-         subscription  =  questionsSnapshotted 
432-           . take ( 1 ) 
433-           . do ( ( data : any )  =>  { 
434-             expect ( data [ 0 ] . val ( ) ) . toEqual ( 'hello snapshot!' ) ; 
435-           } ) 
436-           . subscribe ( ( )  =>  { 
437-             done ( ) ; 
438-           } ,  done . fail ) ; 
427+         subscription  =  _do . call ( skipAndTake ( questionsSnapshotted ,  1 ) , ( data : any )  =>  { 
428+           expect ( data [ 0 ] . val ( ) ) . toEqual ( 'hello snapshot!' ) ; 
429+         } ) 
430+         . subscribe ( ( )  =>  { 
431+           done ( ) ; 
432+         } ,  done . fail ) ; 
439433      } ) ; 
440434    } ) ; 
441435
@@ -543,9 +537,13 @@ describe('FirebaseListFactory', () => {
543537
544538        expect ( unwrappedValueLol . $key ) . toEqual ( 'key' ) ; 
545539        expect ( unwrappedValueLol . $value ) . toEqual ( 'lol' ) ; 
546-         expect ( unwrappedValueLol . $exists ( ) ) . toEqual ( true ) ;          
540+         expect ( unwrappedValueLol . $exists ( ) ) . toEqual ( true ) ; 
547541      } ) ; 
548542    } ) ; 
549543
550544  } ) ; 
551545} ) ; 
546+ 
547+ function  skipAndTake < T > ( obs : Observable < T > ,  takeCount : number  =  1 ,  skipCount : number  =  0 )  { 
548+   return  take . call ( skip . call ( obs ,  skipCount ) ,  takeCount ) ; 
549+ } 
0 commit comments