@@ -92,8 +92,7 @@ describe('AngularFirestoreCollection', () => {
9292 expect ( data . length ) . toEqual ( ITEMS ) ;
9393 pricefilter$ . next ( - 1 ) ;
9494 }
95- // on the second round, make sure the array is still the same
96- // length but the updated item is now modified
95+ // on the second round, we should have filtered out everything
9796 if ( count === 2 ) {
9897 expect ( data . length ) . toEqual ( 0 ) ;
9998 sub . unsubscribe ( ) ;
@@ -193,6 +192,35 @@ describe('AngularFirestoreCollection', () => {
193192 delayAdd ( stocks , nextId , { price : 2 } ) ;
194193 } ) ;
195194
195+ it ( 'should be able to filter snapshotChanges() types - added/modified' , async ( done ) => {
196+ const ITEMS = 10 ;
197+ let { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
198+ const nextId = ref . doc ( 'a' ) . id ;
199+ let count = 0 ;
200+
201+ const sub = stocks . snapshotChanges ( [ 'added' , 'modified' ] ) . skip ( 1 ) . take ( 2 ) . subscribe ( data => {
202+ count += 1 ;
203+ if ( count == 1 ) {
204+ const change = data . filter ( x => x . payload . doc . id === nextId ) [ 0 ] ;
205+ expect ( data . length ) . toEqual ( ITEMS + 1 ) ;
206+ expect ( change . payload . doc . data ( ) . price ) . toEqual ( 2 ) ;
207+ expect ( change . type ) . toEqual ( 'added' ) ;
208+ delayUpdate ( stocks , names [ 0 ] , { price : 2 } ) ;
209+ }
210+ if ( count == 2 ) {
211+ const change = data . filter ( x => x . payload . doc . id === names [ 0 ] ) [ 0 ] ;
212+ expect ( data . length ) . toEqual ( ITEMS + 1 ) ;
213+ expect ( change . payload . doc . data ( ) . price ) . toEqual ( 2 ) ;
214+ expect ( change . type ) . toEqual ( 'modified' ) ;
215+ }
216+ } ) . add ( ( ) => {
217+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
218+ } ) ;
219+
220+ names = names . concat ( [ nextId ] ) ;
221+ delayAdd ( stocks , nextId , { price : 2 } ) ;
222+ } ) ;
223+
196224 it ( 'should be able to filter snapshotChanges() types - removed' , async ( done ) => {
197225 const ITEMS = 10 ;
198226 const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
0 commit comments