@@ -74,28 +74,45 @@ describe('AngularFirestoreCollection', () => {
7474
7575 } ) ;
7676
77- it ( 'should handle multiple subscriptions' , async ( done : any ) => {
77+ it ( 'should handle multiple subscriptions (hot) ' , async ( done : any ) => {
7878 const ITEMS = 4 ;
7979 const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
8080 const changes = stocks . valueChanges ( ) ;
8181 const sub = changes . subscribe ( ( ) => { } ) . add (
82- changes . subscribe ( data => {
82+ changes . take ( 1 ) . subscribe ( data => {
8383 expect ( data . length ) . toEqual ( ITEMS ) ;
8484 sub . unsubscribe ( ) ;
8585 } )
86- ) . add ( done ) ;
86+ ) . add ( ( ) => {
87+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
88+ } ) ;
89+ } ) ;
90+
91+ it ( 'should handle multiple subscriptions (warm)' , async ( done : any ) => {
92+ const ITEMS = 4 ;
93+ const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
94+ const changes = stocks . valueChanges ( ) ;
95+ changes . take ( 1 ) . subscribe ( ( ) => { } ) . add ( ( ) => {
96+ const sub = changes . take ( 1 ) . subscribe ( data => {
97+ expect ( data . length ) . toEqual ( ITEMS ) ;
98+ } ) . add ( ( ) => {
99+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
100+ } ) ;
101+ } ) ;
87102 } ) ;
88103
89- it ( 'should handle multiple subscriptions + cold observer ' , async ( done : any ) => {
104+ it ( 'should handle multiple subscriptions ( cold) ' , async ( done : any ) => {
90105 const ITEMS = 4 ;
91106 const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
92107 const changes = stocks . valueChanges ( ) ;
93- const sub = changes . take ( 1 ) . subscribe ( ( ) => {
108+ const sub = changes . subscribe ( ( ) => {
94109 sub . unsubscribe ( ) ;
95110 } ) . add ( ( ) => {
96111 changes . take ( 1 ) . subscribe ( data => {
97112 expect ( data . length ) . toEqual ( ITEMS ) ;
98- } ) . add ( done ) ;
113+ } ) . add ( ( ) => {
114+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
115+ } ) ;
99116 } ) ;
100117 } ) ;
101118
@@ -132,11 +149,13 @@ describe('AngularFirestoreCollection', () => {
132149 const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
133150 const changes = stocks . snapshotChanges ( ) ;
134151 const sub = changes . subscribe ( ( ) => { } ) . add (
135- changes . subscribe ( data => {
152+ changes . take ( 1 ) . subscribe ( data => {
136153 expect ( data . length ) . toEqual ( ITEMS ) ;
137154 sub . unsubscribe ( ) ;
138155 } )
139- ) . add ( done ) ;
156+ ) . add ( ( ) => {
157+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
158+ } ) ;
140159 } ) ;
141160
142161 it ( 'should update order on queries' , async ( done ) => {
0 commit comments