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