@@ -74,28 +74,45 @@ describe('AngularFirestoreCollection', () => {
74
74
75
75
} ) ;
76
76
77
- it ( 'should handle multiple subscriptions' , async ( done : any ) => {
77
+ it ( 'should handle multiple subscriptions (hot) ' , async ( done : any ) => {
78
78
const ITEMS = 4 ;
79
79
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
80
80
const changes = stocks . valueChanges ( ) ;
81
81
const sub = changes . subscribe ( ( ) => { } ) . add (
82
- changes . subscribe ( data => {
82
+ changes . take ( 1 ) . subscribe ( data => {
83
83
expect ( data . length ) . toEqual ( ITEMS ) ;
84
84
sub . unsubscribe ( ) ;
85
85
} )
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
+ } ) ;
87
102
} ) ;
88
103
89
- it ( 'should handle multiple subscriptions + cold observer ' , async ( done : any ) => {
104
+ it ( 'should handle multiple subscriptions ( cold) ' , async ( done : any ) => {
90
105
const ITEMS = 4 ;
91
106
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
92
107
const changes = stocks . valueChanges ( ) ;
93
- const sub = changes . take ( 1 ) . subscribe ( ( ) => {
108
+ const sub = changes . subscribe ( ( ) => {
94
109
sub . unsubscribe ( ) ;
95
110
} ) . add ( ( ) => {
96
111
changes . take ( 1 ) . subscribe ( data => {
97
112
expect ( data . length ) . toEqual ( ITEMS ) ;
98
- } ) . add ( done ) ;
113
+ } ) . add ( ( ) => {
114
+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
115
+ } ) ;
99
116
} ) ;
100
117
} ) ;
101
118
@@ -132,11 +149,13 @@ describe('AngularFirestoreCollection', () => {
132
149
const { randomCollectionName, ref, stocks, names } = await collectionHarness ( afs , ITEMS ) ;
133
150
const changes = stocks . snapshotChanges ( ) ;
134
151
const sub = changes . subscribe ( ( ) => { } ) . add (
135
- changes . subscribe ( data => {
152
+ changes . take ( 1 ) . subscribe ( data => {
136
153
expect ( data . length ) . toEqual ( ITEMS ) ;
137
154
sub . unsubscribe ( ) ;
138
155
} )
139
- ) . add ( done ) ;
156
+ ) . add ( ( ) => {
157
+ deleteThemAll ( names , ref ) . then ( done ) . catch ( done . fail ) ;
158
+ } ) ;
140
159
} ) ;
141
160
142
161
it ( 'should update order on queries' , async ( done ) => {
0 commit comments