@@ -75,6 +75,33 @@ describe('AngularFirestoreCollection', () => {
7575
7676 } ) ;
7777
78+ it ( 'should handle multiple subscriptions (hot)' , async ( done : any ) => {
79+ const ITEMS = 4 ;
80+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
81+ const changes = stocks . valueChanges ( ) ;
82+ const sub = changes . subscribe ( ( ) => { } ) . add (
83+ changes . take ( 1 ) . subscribe ( data => {
84+ expect ( data . length ) . toEqual ( ITEMS ) ;
85+ sub . unsubscribe ( ) ;
86+ } )
87+ ) . add ( ( ) => {
88+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
89+ } ) ;
90+ } ) ;
91+
92+ it ( 'should handle multiple subscriptions (warm)' , async ( done : any ) => {
93+ const ITEMS = 4 ;
94+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
95+ const changes = stocks . valueChanges ( ) ;
96+ changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
97+ const sub = changes . take ( 1 ) . subscribe ( data => {
98+ expect ( data . length ) . toEqual ( ITEMS ) ;
99+ } ) . add ( ( ) => {
100+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
101+ } ) ;
102+ } ) ;
103+ } ) ;
104+
78105 it ( 'should handle dynamic queries that return empty sets' , async ( done ) => {
79106 const ITEMS = 10 ;
80107 let count = 0 ;
@@ -129,6 +156,33 @@ describe('AngularFirestoreCollection', () => {
129156 } ) ;
130157 } ) ;
131158
159+ it ( 'should handle multiple subscriptions (hot)' , async ( done : any ) => {
160+ const ITEMS = 4 ;
161+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
162+ const changes = stocks . snapshotChanges ( ) ;
163+ const sub = changes . subscribe ( ( ) => { } ) . add (
164+ changes . take ( 1 ) . subscribe ( data => {
165+ expect ( data . length ) . toEqual ( ITEMS ) ;
166+ sub . unsubscribe ( ) ;
167+ } )
168+ ) . add ( ( ) => {
169+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
170+ } ) ;
171+ } ) ;
172+
173+ it ( 'should handle multiple subscriptions (warm)' , async ( done : any ) => {
174+ const ITEMS = 4 ;
175+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
176+ const changes = stocks . snapshotChanges ( ) ;
177+ changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
178+ const sub = changes . take ( 1 ) . subscribe ( data => {
179+ expect ( data . length ) . toEqual ( ITEMS ) ;
180+ } ) . add ( ( ) => {
181+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
182+ } ) ;
183+ } ) ;
184+ } ) ;
185+
132186 it ( 'should update order on queries' , async ( done ) => {
133187 const ITEMS = 10 ;
134188 let count = 0 ;
@@ -279,6 +333,33 @@ describe('AngularFirestoreCollection', () => {
279333 }
280334 } ) ;
281335 } ) ;
336+
337+ it ( 'should handle multiple subscriptions (hot)' , async ( done : any ) => {
338+ const ITEMS = 4 ;
339+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
340+ const changes = stocks . stateChanges ( ) ;
341+ const sub = changes . subscribe ( ( ) => { } ) . add (
342+ changes . take ( 1 ) . subscribe ( data => {
343+ expect ( data . length ) . toEqual ( ITEMS ) ;
344+ sub . unsubscribe ( ) ;
345+ } )
346+ ) . add ( ( ) => {
347+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
348+ } ) ;
349+ } ) ;
350+
351+ it ( 'should handle multiple subscriptions (warm)' , async ( done : any ) => {
352+ const ITEMS = 4 ;
353+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
354+ const changes = stocks . stateChanges ( ) ;
355+ changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
356+ const sub = changes . take ( 1 ) . subscribe ( data => {
357+ expect ( data . length ) . toEqual ( ITEMS ) ;
358+ } ) . add ( ( ) => {
359+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
360+ } ) ;
361+ } ) ;
362+ } ) ;
282363
283364 it ( 'should be able to filter stateChanges() types - modified' , async ( done ) => {
284365 const ITEMS = 10 ;
0 commit comments