@@ -6,11 +6,8 @@ import { AngularFirestoreCollection } from './collection';
6
6
import { QueryFn } from '../interfaces' ;
7
7
8
8
import { FirebaseApp as FBApp } from '@firebase/app-types' ;
9
- import { Observable } from 'rxjs/Observable' ;
10
- import { BehaviorSubject } from 'rxjs/BehaviorSubject' ;
11
- import { of } from 'rxjs/observable/of' ;
12
- import { Subscription } from 'rxjs/Subscription' ;
13
- import 'rxjs/add/operator/skip' ;
9
+ import { Observable , BehaviorSubject , Subscription } from 'rxjs' ;
10
+ import { skip , take , switchMap } from 'rxjs/operators' ;
14
11
15
12
import { TestBed , inject } from '@angular/core/testing' ;
16
13
import { COMMON_CONFIG } from '../test-config' ;
@@ -80,7 +77,7 @@ describe('AngularFirestoreCollection', () => {
80
77
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
81
78
const changes = stocks . valueChanges ( ) ;
82
79
const sub = changes . subscribe ( ( ) => { } ) . add (
83
- changes . take ( 1 ) . subscribe ( data => {
80
+ changes . pipe ( take ( 1 ) ) . subscribe ( data => {
84
81
expect ( data . length ) . toEqual ( ITEMS ) ;
85
82
sub . unsubscribe ( ) ;
86
83
} )
@@ -93,8 +90,8 @@ describe('AngularFirestoreCollection', () => {
93
90
const ITEMS = 4 ;
94
91
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
95
92
const changes = stocks . valueChanges ( ) ;
96
- changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
97
- const sub = changes . take ( 1 ) . subscribe ( data => {
93
+ changes . pipe ( take ( 1 ) ) . subscribe ( ( ) => { } ) . add ( ( ) => {
94
+ const sub = changes . pipe ( take ( 1 ) ) . subscribe ( data => {
98
95
expect ( data . length ) . toEqual ( ITEMS ) ;
99
96
} ) . add ( ( ) => {
100
97
deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
@@ -110,9 +107,9 @@ describe('AngularFirestoreCollection', () => {
110
107
const randomCollectionName = randomName ( afs . firestore ) ;
111
108
const ref = afs . firestore . collection ( `${ randomCollectionName } ` ) ;
112
109
let names = await createRandomStocks ( afs . firestore , ref , ITEMS ) ;
113
- const sub = pricefilter$ . switchMap ( price => {
110
+ const sub = pricefilter$ . pipe ( switchMap ( price => {
114
111
return afs . collection ( randomCollectionName , ref => price ? ref . where ( 'price' , '==' , price ) : ref ) . valueChanges ( )
115
- } ) . subscribe ( data => {
112
+ } ) ) . subscribe ( data => {
116
113
count = count + 1 ;
117
114
// the first time should all be 'added'
118
115
if ( count === 1 ) {
@@ -161,7 +158,7 @@ describe('AngularFirestoreCollection', () => {
161
158
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
162
159
const changes = stocks . snapshotChanges ( ) ;
163
160
const sub = changes . subscribe ( ( ) => { } ) . add (
164
- changes . take ( 1 ) . subscribe ( data => {
161
+ changes . pipe ( take ( 1 ) ) . subscribe ( data => {
165
162
expect ( data . length ) . toEqual ( ITEMS ) ;
166
163
sub . unsubscribe ( ) ;
167
164
} )
@@ -174,8 +171,8 @@ describe('AngularFirestoreCollection', () => {
174
171
const ITEMS = 4 ;
175
172
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
176
173
const changes = stocks . snapshotChanges ( ) ;
177
- changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
178
- const sub = changes . take ( 1 ) . subscribe ( data => {
174
+ changes . pipe ( take ( 1 ) ) . subscribe ( ( ) => { } ) . add ( ( ) => {
175
+ const sub = changes . pipe ( take ( 1 ) ) . subscribe ( data => {
179
176
expect ( data . length ) . toEqual ( ITEMS ) ;
180
177
} ) . add ( ( ) => {
181
178
deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
@@ -214,7 +211,7 @@ describe('AngularFirestoreCollection', () => {
214
211
const ITEMS = 10 ;
215
212
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
216
213
217
- const sub = stocks . snapshotChanges ( [ 'modified' ] ) . skip ( 1 ) . subscribe ( data => {
214
+ const sub = stocks . snapshotChanges ( [ 'modified' ] ) . pipe ( skip ( 1 ) ) . subscribe ( data => {
218
215
sub . unsubscribe ( ) ;
219
216
const change = data . filter ( x => x . payload . doc . id === names [ 0 ] ) [ 0 ] ;
220
217
expect ( data . length ) . toEqual ( 1 ) ;
@@ -231,7 +228,7 @@ describe('AngularFirestoreCollection', () => {
231
228
let { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
232
229
const nextId = ref . doc ( 'a' ) . id ;
233
230
234
- const sub = stocks . snapshotChanges ( [ 'added' ] ) . skip ( 1 ) . subscribe ( data => {
231
+ const sub = stocks . snapshotChanges ( [ 'added' ] ) . pipe ( skip ( 1 ) ) . subscribe ( data => {
235
232
sub . unsubscribe ( ) ;
236
233
const change = data . filter ( x => x . payload . doc . id === nextId ) [ 0 ] ;
237
234
expect ( data . length ) . toEqual ( ITEMS + 1 ) ;
@@ -252,7 +249,7 @@ describe('AngularFirestoreCollection', () => {
252
249
const nextId = ref . doc ( 'a' ) . id ;
253
250
let count = 0 ;
254
251
255
- const sub = stocks . snapshotChanges ( [ 'added' , 'modified' ] ) . skip ( 1 ) . take ( 2 ) . subscribe ( data => {
252
+ const sub = stocks . snapshotChanges ( [ 'added' , 'modified' ] ) . pipe ( skip ( 1 ) , take ( 2 ) ) . subscribe ( data => {
256
253
count += 1 ;
257
254
if ( count == 1 ) {
258
255
const change = data . filter ( x => x . payload . doc . id === nextId ) [ 0 ] ;
@@ -279,7 +276,7 @@ describe('AngularFirestoreCollection', () => {
279
276
const ITEMS = 10 ;
280
277
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
281
278
282
- const sub = stocks . snapshotChanges ( [ 'added' , 'removed' ] ) . skip ( 1 ) . subscribe ( data => {
279
+ const sub = stocks . snapshotChanges ( [ 'added' , 'removed' ] ) . pipe ( skip ( 1 ) ) . subscribe ( data => {
283
280
sub . unsubscribe ( ) ;
284
281
const change = data . filter ( x => x . payload . doc . id === names [ 0 ] ) ;
285
282
expect ( data . length ) . toEqual ( ITEMS - 1 ) ;
@@ -339,7 +336,7 @@ describe('AngularFirestoreCollection', () => {
339
336
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
340
337
const changes = stocks . stateChanges ( ) ;
341
338
const sub = changes . subscribe ( ( ) => { } ) . add (
342
- changes . take ( 1 ) . subscribe ( data => {
339
+ changes . pipe ( take ( 1 ) ) . subscribe ( data => {
343
340
expect ( data . length ) . toEqual ( ITEMS ) ;
344
341
sub . unsubscribe ( ) ;
345
342
} )
@@ -352,8 +349,8 @@ describe('AngularFirestoreCollection', () => {
352
349
const ITEMS = 4 ;
353
350
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
354
351
const changes = stocks . stateChanges ( ) ;
355
- changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
356
- const sub = changes . take ( 1 ) . subscribe ( data => {
352
+ changes . pipe ( take ( 1 ) ) . subscribe ( ( ) => { } ) . add ( ( ) => {
353
+ const sub = changes . pipe ( take ( 1 ) ) . subscribe ( data => {
357
354
expect ( data . length ) . toEqual ( ITEMS ) ;
358
355
} ) . add ( ( ) => {
359
356
deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
@@ -383,7 +380,7 @@ describe('AngularFirestoreCollection', () => {
383
380
let count = 0 ;
384
381
let { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
385
382
386
- const sub = stocks . stateChanges ( [ 'added' ] ) . skip ( 1 ) . subscribe ( data => {
383
+ const sub = stocks . stateChanges ( [ 'added' ] ) . pipe ( skip ( 1 ) ) . subscribe ( data => {
387
384
sub . unsubscribe ( ) ;
388
385
expect ( data . length ) . toEqual ( 1 ) ;
389
386
expect ( data [ 0 ] . payload . doc . data ( ) . price ) . toEqual ( 2 ) ;
0 commit comments