@@ -95,7 +95,10 @@ apiDescribe('Bundles', (persistence: boolean) => {
95
95
return withTestDb ( persistence , async db => {
96
96
const progressEvents : firestore . LoadBundleTaskProgress [ ] = [ ] ;
97
97
let completeCalled = false ;
98
- const task : firestore . LoadBundleTask = db . loadBundle ( bundleString ( db ) ) ;
98
+ const task : firestore . LoadBundleTask = firestore . loadBundle (
99
+ db ,
100
+ bundleString ( db )
101
+ ) ;
99
102
task . onProgress (
100
103
progress => {
101
104
progressEvents . push ( progress ) ;
@@ -124,12 +127,12 @@ apiDescribe('Bundles', (persistence: boolean) => {
124
127
let snap = await db . collection ( 'coll-1' ) . get ( { source : 'cache' } ) ;
125
128
verifySnapEqualsTestDocs ( snap ) ;
126
129
127
- snap = await ( await db . namedQuery ( 'limit' ) ) ! . get ( {
130
+ snap = await ( await firestore . namedQuery ( db , 'limit' ) ) ! . get ( {
128
131
source : 'cache'
129
132
} ) ;
130
133
expect ( toDataArray ( snap ) ) . to . deep . equal ( [ { k : 'b' , bar : 2 } ] ) ;
131
134
132
- snap = await ( await db . namedQuery ( 'limit-to-last' ) ) ! . get ( {
135
+ snap = await ( await firestore . namedQuery ( db , 'limit-to-last' ) ) ! . get ( {
133
136
source : 'cache'
134
137
} ) ;
135
138
expect ( toDataArray ( snap ) ) . to . deep . equal ( [ { k : 'a' , bar : 1 } ] ) ;
@@ -138,7 +141,8 @@ apiDescribe('Bundles', (persistence: boolean) => {
138
141
139
142
it ( 'load with documents and queries with promise interface' , ( ) => {
140
143
return withTestDb ( persistence , async db => {
141
- const fulfillProgress : firestore . LoadBundleTaskProgress = await db . loadBundle (
144
+ const fulfillProgress : firestore . LoadBundleTaskProgress = await firestore . loadBundle (
145
+ db ,
142
146
bundleString ( db )
143
147
) ;
144
148
@@ -153,11 +157,12 @@ apiDescribe('Bundles', (persistence: boolean) => {
153
157
154
158
it ( 'load for a second time skips' , ( ) => {
155
159
return withTestDb ( persistence , async db => {
156
- await db . loadBundle ( bundleString ( db ) ) ;
160
+ await firestore . loadBundle ( db , bundleString ( db ) ) ;
157
161
158
162
let completeCalled = false ;
159
163
const progressEvents : firestore . LoadBundleTaskProgress [ ] = [ ] ;
160
- const task : firestore . LoadBundleTask = db . loadBundle (
164
+ const task : firestore . LoadBundleTask = firestore . loadBundle (
165
+ db ,
161
166
encoder . encode ( bundleString ( db ) )
162
167
) ;
163
168
task . onProgress (
@@ -193,7 +198,8 @@ apiDescribe('Bundles', (persistence: boolean) => {
193
198
db . collection ( 'coll-1' ) . onSnapshot ( accumulator . storeEvent ) ;
194
199
await accumulator . awaitEvent ( ) ;
195
200
196
- const progress = await db . loadBundle (
201
+ const progress = await firestore . loadBundle (
202
+ db ,
197
203
// Testing passing in non-string bundles.
198
204
encoder . encode ( bundleString ( db ) )
199
205
) ;
@@ -204,17 +210,18 @@ apiDescribe('Bundles', (persistence: boolean) => {
204
210
// cache can only be tested in spec tests.
205
211
await accumulator . assertNoAdditionalEvents ( ) ;
206
212
207
- let snap = await ( await db . namedQuery ( 'limit' ) ) ! . get ( ) ;
213
+ let snap = await ( await firestore . namedQuery ( db , 'limit' ) ) ! . get ( ) ;
208
214
expect ( toDataArray ( snap ) ) . to . deep . equal ( [ { k : 'b' , bar : 0 } ] ) ;
209
215
210
- snap = await ( await db . namedQuery ( 'limit-to-last' ) ) ! . get ( ) ;
216
+ snap = await ( await firestore . namedQuery ( db , 'limit-to-last' ) ) ! . get ( ) ;
211
217
expect ( toDataArray ( snap ) ) . to . deep . equal ( [ { k : 'a' , bar : 0 } ] ) ;
212
218
} ) ;
213
219
} ) ;
214
220
215
221
it ( 'loaded documents should not be GC-ed right away' , ( ) => {
216
222
return withTestDb ( persistence , async db => {
217
- const fulfillProgress : firestore . LoadBundleTaskProgress = await db . loadBundle (
223
+ const fulfillProgress : firestore . LoadBundleTaskProgress = await firestore . loadBundle (
224
+ db ,
218
225
bundleString ( db )
219
226
) ;
220
227
@@ -235,12 +242,15 @@ apiDescribe('Bundles', (persistence: boolean) => {
235
242
it ( 'load with documents from other projects fails' , ( ) => {
236
243
return withTestDb ( persistence , async db => {
237
244
return withAlternateTestDb ( persistence , async otherDb => {
238
- await expect ( otherDb . loadBundle ( bundleString ( db ) ) ) . to . be . rejectedWith (
239
- 'Tried to deserialize key from different project'
240
- ) ;
245
+ await expect (
246
+ firestore . loadBundle ( otherDb , bundleString ( db ) )
247
+ ) . to . be . rejectedWith ( 'Tried to deserialize key from different project' ) ;
241
248
242
249
// Verify otherDb still functions, despite loaded a problematic bundle.
243
- const finalProgress = await otherDb . loadBundle ( bundleString ( otherDb ) ) ;
250
+ const finalProgress = await firestore . loadBundle (
251
+ otherDb ,
252
+ bundleString ( otherDb )
253
+ ) ;
244
254
verifySuccessProgress ( finalProgress ) ;
245
255
246
256
// Read from cache. These documents do not exist in backend, so they can
0 commit comments