@react-native-firebase/firestore 21.7.4 → 21.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/__tests__/firestore.test.ts +0 -1401
|
@@ -1,1401 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, jest, beforeEach } from '@jest/globals';
|
|
2
|
-
// @ts-ignore test
|
|
3
|
-
import { createDeprecationProxy } from '../../app/lib/common';
|
|
4
|
-
// @ts-ignore test
|
|
5
|
-
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
|
|
6
|
-
// @ts-ignore test
|
|
7
|
-
import FirestoreQuery from '../lib/FirestoreQuery';
|
|
8
|
-
// @ts-ignore test
|
|
9
|
-
import FirestoreDocumentSnapshot from '../lib/FirestoreDocumentSnapshot';
|
|
10
|
-
// @ts-ignore test
|
|
11
|
-
import * as nativeModule from '@react-native-firebase/app/lib/internal/nativeModuleAndroidIos';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
createCheckV9Deprecation,
|
|
15
|
-
CheckV9DeprecationFunction,
|
|
16
|
-
} from '../../app/lib/common/unitTestUtils';
|
|
17
|
-
|
|
18
|
-
import { getApp } from '../../app/lib/modular';
|
|
19
|
-
import firestore, {
|
|
20
|
-
firebase,
|
|
21
|
-
connectFirestoreEmulator,
|
|
22
|
-
Filter,
|
|
23
|
-
getFirestore,
|
|
24
|
-
getAggregateFromServer,
|
|
25
|
-
count,
|
|
26
|
-
average,
|
|
27
|
-
sum,
|
|
28
|
-
addDoc,
|
|
29
|
-
doc,
|
|
30
|
-
collection,
|
|
31
|
-
collectionGroup,
|
|
32
|
-
setDoc,
|
|
33
|
-
updateDoc,
|
|
34
|
-
enableNetwork,
|
|
35
|
-
disableNetwork,
|
|
36
|
-
clearPersistence,
|
|
37
|
-
clearIndexedDbPersistence,
|
|
38
|
-
terminate,
|
|
39
|
-
waitForPendingWrites,
|
|
40
|
-
initializeFirestore,
|
|
41
|
-
setLogLevel,
|
|
42
|
-
runTransaction,
|
|
43
|
-
getCountFromServer,
|
|
44
|
-
loadBundle,
|
|
45
|
-
namedQuery,
|
|
46
|
-
writeBatch,
|
|
47
|
-
Bytes,
|
|
48
|
-
FieldPath,
|
|
49
|
-
FieldValue,
|
|
50
|
-
deleteField,
|
|
51
|
-
serverTimestamp,
|
|
52
|
-
arrayUnion,
|
|
53
|
-
arrayRemove,
|
|
54
|
-
increment,
|
|
55
|
-
GeoPoint,
|
|
56
|
-
query,
|
|
57
|
-
where,
|
|
58
|
-
or,
|
|
59
|
-
and,
|
|
60
|
-
orderBy,
|
|
61
|
-
startAt,
|
|
62
|
-
startAfter,
|
|
63
|
-
endAt,
|
|
64
|
-
endBefore,
|
|
65
|
-
limit,
|
|
66
|
-
limitToLast,
|
|
67
|
-
getDoc,
|
|
68
|
-
getDocFromCache,
|
|
69
|
-
getDocFromServer,
|
|
70
|
-
getDocs,
|
|
71
|
-
getDocsFromCache,
|
|
72
|
-
getDocsFromServer,
|
|
73
|
-
deleteDoc,
|
|
74
|
-
onSnapshot,
|
|
75
|
-
Timestamp,
|
|
76
|
-
getPersistentCacheIndexManager,
|
|
77
|
-
deleteAllPersistentCacheIndexes,
|
|
78
|
-
disablePersistentCacheIndexAutoCreation,
|
|
79
|
-
enablePersistentCacheIndexAutoCreation,
|
|
80
|
-
} from '../lib';
|
|
81
|
-
|
|
82
|
-
const COLLECTION = 'firestore';
|
|
83
|
-
|
|
84
|
-
describe('Firestore', function () {
|
|
85
|
-
describe('namespace', function () {
|
|
86
|
-
it('accessible from firebase.app()', function () {
|
|
87
|
-
const app = firebase.app();
|
|
88
|
-
expect(app.firestore).toBeDefined();
|
|
89
|
-
expect(app.firestore().settings).toBeDefined();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('batch()', function () {
|
|
94
|
-
it('returns a new WriteBatch instance', function () {
|
|
95
|
-
const instance = firebase.firestore().batch();
|
|
96
|
-
return expect(instance.constructor.name).toEqual('FirestoreWriteBatch');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('settings', function () {
|
|
101
|
-
it('throws if settings is not an object', async function () {
|
|
102
|
-
try {
|
|
103
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
104
|
-
await firebase.firestore().settings('foo');
|
|
105
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
106
|
-
} catch (e: any) {
|
|
107
|
-
return expect(e.message).toContain("'settings' must be an object");
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('throws if passing an incorrect setting key', async function () {
|
|
112
|
-
try {
|
|
113
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
114
|
-
await firebase.firestore().settings({ foo: 'bar' });
|
|
115
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
116
|
-
} catch (e: any) {
|
|
117
|
-
return expect(e.message).toContain("'settings.foo' is not a valid settings field");
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('throws if cacheSizeBytes is not a number', async function () {
|
|
122
|
-
try {
|
|
123
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
124
|
-
await firebase.firestore().settings({ cacheSizeBytes: 'foo' });
|
|
125
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
126
|
-
} catch (e: any) {
|
|
127
|
-
return expect(e.message).toContain("'settings.cacheSizeBytes' must be a number value");
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('throws if cacheSizeBytes is less than 1MB', async function () {
|
|
132
|
-
try {
|
|
133
|
-
await firebase.firestore().settings({ cacheSizeBytes: 123 });
|
|
134
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
135
|
-
} catch (e: any) {
|
|
136
|
-
return expect(e.message).toContain("'settings.cacheSizeBytes' the minimum cache size");
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('accepts an unlimited cache size', async function () {
|
|
141
|
-
await firebase
|
|
142
|
-
.firestore()
|
|
143
|
-
.settings({ cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED });
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('throws if host is not a string', async function () {
|
|
147
|
-
try {
|
|
148
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
149
|
-
await firebase.firestore().settings({ host: 123 });
|
|
150
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
151
|
-
} catch (e: any) {
|
|
152
|
-
return expect(e.message).toContain("'settings.host' must be a string value");
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('throws if host is an empty string', async function () {
|
|
157
|
-
try {
|
|
158
|
-
await firebase.firestore().settings({ host: '' });
|
|
159
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
160
|
-
} catch (e: any) {
|
|
161
|
-
return expect(e.message).toContain("'settings.host' must not be an empty string");
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('throws if persistence is not a boolean', async function () {
|
|
166
|
-
try {
|
|
167
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
168
|
-
await firebase.firestore().settings({ persistence: 'true' });
|
|
169
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
170
|
-
} catch (e: any) {
|
|
171
|
-
return expect(e.message).toContain("'settings.persistence' must be a boolean value");
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('throws if ssl is not a boolean', async function () {
|
|
176
|
-
try {
|
|
177
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
178
|
-
await firebase.firestore().settings({ ssl: 'true' });
|
|
179
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
180
|
-
} catch (e: any) {
|
|
181
|
-
return expect(e.message).toContain("'settings.ssl' must be a boolean value");
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('throws if ignoreUndefinedProperties is not a boolean', async function () {
|
|
186
|
-
try {
|
|
187
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
188
|
-
await firestore().settings({ ignoreUndefinedProperties: 'bogus' });
|
|
189
|
-
return Promise.reject(new Error('Should throw'));
|
|
190
|
-
} catch (e: any) {
|
|
191
|
-
return expect(e.message).toContain("ignoreUndefinedProperties' must be a boolean value.");
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("throws if serverTimestampBehavior is not one of 'estimate', 'previous', 'none'", async function () {
|
|
196
|
-
try {
|
|
197
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
198
|
-
await firestore().settings({ serverTimestampBehavior: 'bogus' });
|
|
199
|
-
return Promise.reject(new Error('Should throw'));
|
|
200
|
-
} catch (e: any) {
|
|
201
|
-
return expect(e.message).toContain(
|
|
202
|
-
"serverTimestampBehavior' must be one of 'estimate', 'previous', 'none'",
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe('runTransaction()', function () {
|
|
209
|
-
it('throws if updateFunction is not a function', async function () {
|
|
210
|
-
try {
|
|
211
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
212
|
-
await firebase.firestore().runTransaction('foo');
|
|
213
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
214
|
-
} catch (e: any) {
|
|
215
|
-
return expect(e.message).toContain("'updateFunction' must be a function");
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe('collectionGroup()', function () {
|
|
221
|
-
it('returns a new query instance', function () {
|
|
222
|
-
const query = firebase.firestore().collectionGroup(COLLECTION);
|
|
223
|
-
expect(query.constructor.name).toEqual('FirestoreQuery');
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('throws if id is not a string', async function () {
|
|
227
|
-
try {
|
|
228
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
229
|
-
firebase.firestore().collectionGroup(123);
|
|
230
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
231
|
-
} catch (e: any) {
|
|
232
|
-
return expect(e.message).toContain("'collectionId' must be a string value");
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('throws if id is empty', async function () {
|
|
237
|
-
try {
|
|
238
|
-
firebase.firestore().collectionGroup('');
|
|
239
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
240
|
-
} catch (e: any) {
|
|
241
|
-
return expect(e.message).toContain("'collectionId' must be a non-empty string");
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('throws if id contains forward-slash', async function () {
|
|
246
|
-
try {
|
|
247
|
-
firebase.firestore().collectionGroup(`someCollection/bar`);
|
|
248
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
249
|
-
} catch (e: any) {
|
|
250
|
-
return expect(e.message).toContain("'collectionId' must not contain '/'");
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
describe('collection()', function () {
|
|
256
|
-
it('throws if path is not a string', async function () {
|
|
257
|
-
try {
|
|
258
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
259
|
-
firebase.firestore().collection(123);
|
|
260
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
261
|
-
} catch (e: any) {
|
|
262
|
-
return expect(e.message).toContain("'collectionPath' must be a string value");
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('throws if path is empty string', async function () {
|
|
267
|
-
try {
|
|
268
|
-
firebase.firestore().collection('');
|
|
269
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
270
|
-
} catch (e: any) {
|
|
271
|
-
return expect(e.message).toContain("'collectionPath' must be a non-empty string");
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('throws if path does not point to a collection', async function () {
|
|
276
|
-
try {
|
|
277
|
-
firebase.firestore().collection(`firestore/bar`);
|
|
278
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
279
|
-
} catch (e: any) {
|
|
280
|
-
return expect(e.message).toContain("'collectionPath' must point to a collection");
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('returns a new CollectionReference', async function () {
|
|
285
|
-
const collectionReference = firebase.firestore().collection('firestore');
|
|
286
|
-
expect(collectionReference.constructor.name).toEqual('FirestoreCollectionReference');
|
|
287
|
-
expect(collectionReference.path).toEqual('firestore');
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
describe('doc()', function () {
|
|
292
|
-
it('throws if path is not a string', async function () {
|
|
293
|
-
try {
|
|
294
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
295
|
-
firebase.firestore().doc(123);
|
|
296
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
297
|
-
} catch (e: any) {
|
|
298
|
-
return expect(e.message).toContain("'documentPath' must be a string value");
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('throws if path is empty string', async function () {
|
|
303
|
-
try {
|
|
304
|
-
firebase.firestore().doc('');
|
|
305
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
306
|
-
} catch (e: any) {
|
|
307
|
-
return expect(e.message).toContain("'documentPath' must be a non-empty string");
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('throws if path does not point to a document', async function () {
|
|
312
|
-
try {
|
|
313
|
-
firebase.firestore().doc(`${COLLECTION}/bar/baz`);
|
|
314
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
315
|
-
} catch (e: any) {
|
|
316
|
-
return expect(e.message).toContain("'documentPath' must point to a document");
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('returns a new DocumentReference', async function () {
|
|
321
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
322
|
-
expect(docRef.constructor.name).toEqual('FirestoreDocumentReference');
|
|
323
|
-
expect(docRef.path).toEqual(`${COLLECTION}/bar`);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('throws when undefined value provided and ignored undefined is false', async function () {
|
|
327
|
-
await firebase.firestore().settings({ ignoreUndefinedProperties: false });
|
|
328
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
329
|
-
try {
|
|
330
|
-
await docRef.set({
|
|
331
|
-
field1: 1,
|
|
332
|
-
field2: undefined,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
return Promise.reject(new Error('Expected set() to throw'));
|
|
336
|
-
} catch (e: any) {
|
|
337
|
-
return expect(e.message).toEqual('Unsupported field value: undefined');
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it('throws when nested undefined object value provided and ignored undefined is false', async function () {
|
|
342
|
-
await firebase.firestore().settings({ ignoreUndefinedProperties: false });
|
|
343
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
344
|
-
try {
|
|
345
|
-
await docRef.set({
|
|
346
|
-
field1: 1,
|
|
347
|
-
field2: {
|
|
348
|
-
shouldNotWork: undefined,
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
return Promise.reject(new Error('Expected set() to throw'));
|
|
352
|
-
} catch (e: any) {
|
|
353
|
-
return expect(e.message).toEqual('Unsupported field value: undefined');
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('throws when nested undefined array value provided and ignored undefined is false', async function () {
|
|
358
|
-
await firebase.firestore().settings({ ignoreUndefinedProperties: false });
|
|
359
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
360
|
-
try {
|
|
361
|
-
await docRef.set({
|
|
362
|
-
myArray: [{ name: 'Tim', location: { state: undefined, country: 'United Kingdom' } }],
|
|
363
|
-
});
|
|
364
|
-
return Promise.reject(new Error('Expected set() to throw'));
|
|
365
|
-
} catch (e: any) {
|
|
366
|
-
return expect(e.message).toEqual('Unsupported field value: undefined');
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it('does not throw when nested undefined array value provided and ignore undefined is true', async function () {
|
|
371
|
-
await firebase.firestore().settings({ ignoreUndefinedProperties: true });
|
|
372
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
373
|
-
await docRef.set({
|
|
374
|
-
myArray: [{ name: 'Tim', location: { state: undefined, country: 'United Kingdom' } }],
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it('does not throw when nested undefined object value provided and ignore undefined is true', async function () {
|
|
379
|
-
await firebase.firestore().settings({ ignoreUndefinedProperties: true });
|
|
380
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
381
|
-
await docRef.set({
|
|
382
|
-
field1: 1,
|
|
383
|
-
field2: {
|
|
384
|
-
shouldNotWork: undefined,
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it('does not throw when Date is provided instead of Timestamp', async function () {
|
|
390
|
-
// type BarType = {
|
|
391
|
-
// myDate: FirebaseFirestoreTypes.Timestamp;
|
|
392
|
-
// };
|
|
393
|
-
|
|
394
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
395
|
-
await docRef.set({
|
|
396
|
-
myDate: new Date(),
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
it('does not throw when serverTimestamp is provided instead of Timestamp', async function () {
|
|
401
|
-
// type BarType = {
|
|
402
|
-
// myDate: FirebaseFirestoreTypes.Timestamp;
|
|
403
|
-
// };
|
|
404
|
-
|
|
405
|
-
const docRef = firebase.firestore().doc(`${COLLECTION}/bar`);
|
|
406
|
-
await docRef.set({
|
|
407
|
-
myDate: firestore.FieldValue.serverTimestamp(),
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
describe('loadBundle()', function () {
|
|
413
|
-
it('throws if bundle is not a string', async function () {
|
|
414
|
-
try {
|
|
415
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
416
|
-
firebase.firestore().loadBundle(123);
|
|
417
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
418
|
-
} catch (e: any) {
|
|
419
|
-
return expect(e.message).toContain("'bundle' must be a string value");
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('throws if bundle is empty string', async function () {
|
|
424
|
-
try {
|
|
425
|
-
firebase.firestore().loadBundle('');
|
|
426
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
427
|
-
} catch (e: any) {
|
|
428
|
-
return expect(e.message).toContain("'bundle' must be a non-empty string");
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
describe('namedQuery()', function () {
|
|
434
|
-
it('throws if queryName is not a string', async function () {
|
|
435
|
-
try {
|
|
436
|
-
// @ts-ignore the type is incorrect *on purpose* to test type checking in javascript
|
|
437
|
-
firebase.firestore().namedQuery(123);
|
|
438
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
439
|
-
} catch (e: any) {
|
|
440
|
-
return expect(e.message).toContain("'queryName' must be a string value");
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
it('throws if queryName is empty string', async function () {
|
|
445
|
-
try {
|
|
446
|
-
firebase.firestore().namedQuery('');
|
|
447
|
-
return Promise.reject(new Error('Did not throw an Error.'));
|
|
448
|
-
} catch (e: any) {
|
|
449
|
-
return expect(e.message).toContain("'queryName' must be a non-empty string");
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
describe('modular', function () {
|
|
455
|
-
it('`getFirestore` function is properly exposed to end user', function () {
|
|
456
|
-
expect(getFirestore).toBeDefined();
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('`Filter` is properly exposed to end user', async function () {
|
|
460
|
-
const filter1 = Filter('name', '==', 'Tim');
|
|
461
|
-
const filter2 = Filter('age', '>', 21);
|
|
462
|
-
|
|
463
|
-
// @ts-ignore
|
|
464
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
465
|
-
const query = Filter.and(filter1, filter2);
|
|
466
|
-
// @ts-ignore
|
|
467
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
468
|
-
const query2 = Filter.or(filter1, filter2);
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
it('`doc` function is properly exposed to end user', function () {
|
|
472
|
-
expect(doc).toBeDefined();
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it('`collection` function is properly exposed to end user', function () {
|
|
476
|
-
expect(collection).toBeDefined();
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
it('`collectionGroup` function is properly exposed to end user', function () {
|
|
480
|
-
expect(collectionGroup).toBeDefined();
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
it('`setDoc` function is properly exposed to end user', function () {
|
|
484
|
-
expect(setDoc).toBeDefined();
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
it('`updateDoc` function is properly exposed to end user', function () {
|
|
488
|
-
expect(updateDoc).toBeDefined();
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
it('`addDoc` function is properly exposed to end user', function () {
|
|
492
|
-
expect(addDoc).toBeDefined();
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
it('`enableNetwork` function is properly exposed to end user', function () {
|
|
496
|
-
expect(enableNetwork).toBeDefined();
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('`disableNetwork` function is properly exposed to end user', function () {
|
|
500
|
-
expect(disableNetwork).toBeDefined();
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
it('`clearPersistence` function is properly exposed to end user', function () {
|
|
504
|
-
expect(clearPersistence).toBeDefined();
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
it('`terminate` function is properly exposed to end user', function () {
|
|
508
|
-
expect(terminate).toBeDefined();
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
it('`waitForPendingWrites` function is properly exposed to end user', function () {
|
|
512
|
-
expect(waitForPendingWrites).toBeDefined();
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
it('`initializeFirestore` function is properly exposed to end user', function () {
|
|
516
|
-
expect(initializeFirestore).toBeDefined();
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it('`setLogLevel` function is properly exposed to end user', function () {
|
|
520
|
-
expect(setLogLevel).toBeDefined();
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
it('`runTransaction` function is properly exposed to end user', function () {
|
|
524
|
-
expect(runTransaction).toBeDefined();
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
it('`getCountFromServer` function is properly exposed to end user', function () {
|
|
528
|
-
expect(getCountFromServer).toBeDefined();
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it('`loadBundle` function is properly exposed to end user', function () {
|
|
532
|
-
expect(loadBundle).toBeDefined();
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
it('`namedQuery` function is properly exposed to end user', function () {
|
|
536
|
-
expect(namedQuery).toBeDefined();
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
it('`writeBatch` function is properly exposed to end user', function () {
|
|
540
|
-
expect(writeBatch).toBeDefined();
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it('`Bytes` class is properly exposed to end user', function () {
|
|
544
|
-
expect(Bytes).toBeDefined();
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it('`FieldPath` class is properly exposed to end user', function () {
|
|
548
|
-
expect(FieldPath).toBeDefined();
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it('`FieldValue` is properly exposed to end user', function () {
|
|
552
|
-
expect(FieldValue).toBeDefined();
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
it('`deleteField` function is properly exposed to end user', function () {
|
|
556
|
-
expect(deleteField).toBeDefined();
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
it('`serverTimestamp` function is properly exposed to end user', function () {
|
|
560
|
-
expect(serverTimestamp).toBeDefined();
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
it('`arrayUnion` function is properly exposed to end user', function () {
|
|
564
|
-
expect(arrayUnion).toBeDefined();
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
it('`arrayRemove` function is properly exposed to end user', function () {
|
|
568
|
-
expect(arrayRemove).toBeDefined();
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
it('`increment` function is properly exposed to end user', function () {
|
|
572
|
-
expect(increment).toBeDefined();
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
it('`GeoPoint` is properly exposed to end user', function () {
|
|
576
|
-
expect(GeoPoint).toBeDefined();
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
it('`query` function is properly exposed to end user', function () {
|
|
580
|
-
expect(query).toBeDefined();
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
it('`where` function is properly exposed to end user', function () {
|
|
584
|
-
expect(where).toBeDefined();
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
it('`or` function is properly exposed to end user', function () {
|
|
588
|
-
expect(or).toBeDefined();
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
it('`and` function is properly exposed to end user', function () {
|
|
592
|
-
expect(and).toBeDefined();
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
it('`orderBy` function is properly exposed to end user', function () {
|
|
596
|
-
expect(orderBy).toBeDefined();
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
it('`startAt` function is properly exposed to end user', function () {
|
|
600
|
-
expect(startAt).toBeDefined();
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
it('`startAfter` function is properly exposed to end user', function () {
|
|
604
|
-
expect(startAfter).toBeDefined();
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
it('`endAt` function is properly exposed to end user', function () {
|
|
608
|
-
expect(endAt).toBeDefined();
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
it('`endBefore` function is properly exposed to end user', function () {
|
|
612
|
-
expect(endBefore).toBeDefined();
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
it('`limit` function is properly exposed to end user', function () {
|
|
616
|
-
expect(limit).toBeDefined();
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
it('`limitToLast` function is properly exposed to end user', function () {
|
|
620
|
-
expect(limitToLast).toBeDefined();
|
|
621
|
-
});
|
|
622
|
-
|
|
623
|
-
it('`getDoc` function is properly exposed to end user', function () {
|
|
624
|
-
expect(getDoc).toBeDefined();
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
it('`getDocFromCache` function is properly exposed to end user', function () {
|
|
628
|
-
expect(getDocFromCache).toBeDefined();
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
it('`getDocFromServer` function is properly exposed to end user', function () {
|
|
632
|
-
expect(getDocFromServer).toBeDefined();
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it('`getDocs` function is properly exposed to end user', function () {
|
|
636
|
-
expect(getDocs).toBeDefined();
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
it('`getDocsFromCache` function is properly exposed to end user', function () {
|
|
640
|
-
expect(getDocsFromCache).toBeDefined();
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
it('`getDocsFromServer` function is properly exposed to end user', function () {
|
|
644
|
-
expect(getDocsFromServer).toBeDefined();
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
it('`deleteDoc` function is properly exposed to end user', function () {
|
|
648
|
-
expect(deleteDoc).toBeDefined();
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
it('`onSnapshot` function is properly exposed to end user', function () {
|
|
652
|
-
expect(onSnapshot).toBeDefined();
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
it('`Timestamp` is properly exposed to end user', function () {
|
|
656
|
-
expect(Timestamp).toBeDefined();
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
it('`getPersistentCacheIndexManager` is properly exposed to end user', function () {
|
|
660
|
-
expect(getPersistentCacheIndexManager).toBeDefined();
|
|
661
|
-
const indexManager = getPersistentCacheIndexManager(firebase.firestore());
|
|
662
|
-
expect(indexManager!.constructor.name).toEqual('FirestorePersistentCacheIndexManager');
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
it('`deleteAllPersistentCacheIndexes` is properly exposed to end user', function () {
|
|
666
|
-
expect(deleteAllPersistentCacheIndexes).toBeDefined();
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
it('`disablePersistentCacheIndexAutoCreation` is properly exposed to end user', function () {
|
|
670
|
-
expect(disablePersistentCacheIndexAutoCreation).toBeDefined();
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
it('`enablePersistentCacheIndexAutoCreation` is properly exposed to end user', function () {
|
|
674
|
-
expect(enablePersistentCacheIndexAutoCreation).toBeDefined();
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
it('`getAggregateFromServer` is properly exposed to end user', function () {
|
|
678
|
-
expect(getAggregateFromServer).toBeDefined();
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
it('`count` is properly exposed to end user', function () {
|
|
682
|
-
expect(count).toBeDefined();
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
it('`average` is properly exposed to end user', function () {
|
|
686
|
-
expect(average).toBeDefined();
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it('`sum` is properly exposed to end user', function () {
|
|
690
|
-
expect(sum).toBeDefined();
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
describe('FirestorePersistentCacheIndexManager', function () {
|
|
695
|
-
it('is exposed to end user', function () {
|
|
696
|
-
const firestore1 = firebase.firestore();
|
|
697
|
-
firestore1.settings({ persistence: true });
|
|
698
|
-
const indexManager = firestore1.persistentCacheIndexManager();
|
|
699
|
-
expect(indexManager).toBeDefined();
|
|
700
|
-
expect(indexManager!.constructor.name).toEqual('FirestorePersistentCacheIndexManager');
|
|
701
|
-
|
|
702
|
-
expect(indexManager!.enableIndexAutoCreation).toBeInstanceOf(Function);
|
|
703
|
-
expect(indexManager!.disableIndexAutoCreation).toBeInstanceOf(Function);
|
|
704
|
-
expect(indexManager!.deleteAllIndexes).toBeInstanceOf(Function);
|
|
705
|
-
|
|
706
|
-
const firestore2 = firebase.firestore();
|
|
707
|
-
firestore2.settings({ persistence: false });
|
|
708
|
-
|
|
709
|
-
const nullIndexManager = firestore2.persistentCacheIndexManager();
|
|
710
|
-
|
|
711
|
-
expect(nullIndexManager).toBeNull();
|
|
712
|
-
|
|
713
|
-
const nullIndexManagerModular = getPersistentCacheIndexManager(firestore2);
|
|
714
|
-
expect(nullIndexManagerModular).toBeNull();
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
|
|
719
|
-
let collectionRefV9Deprecation: CheckV9DeprecationFunction;
|
|
720
|
-
let docRefV9Deprecation: CheckV9DeprecationFunction;
|
|
721
|
-
let fieldValueV9Deprecation: CheckV9DeprecationFunction;
|
|
722
|
-
let filterV9Deprecation: CheckV9DeprecationFunction;
|
|
723
|
-
let persistentCacheIndexManagerV9Deprecation: CheckV9DeprecationFunction;
|
|
724
|
-
let firestoreRefV9Deprecation: CheckV9DeprecationFunction;
|
|
725
|
-
let staticsV9Deprecation: CheckV9DeprecationFunction;
|
|
726
|
-
let timestampV9Deprecation: CheckV9DeprecationFunction;
|
|
727
|
-
|
|
728
|
-
beforeEach(function () {
|
|
729
|
-
firestoreRefV9Deprecation = createCheckV9Deprecation(['firestore']);
|
|
730
|
-
collectionRefV9Deprecation = createCheckV9Deprecation([
|
|
731
|
-
'firestore',
|
|
732
|
-
'FirestoreCollectionReference',
|
|
733
|
-
]);
|
|
734
|
-
|
|
735
|
-
docRefV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreDocumentReference']);
|
|
736
|
-
|
|
737
|
-
fieldValueV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreFieldValue']);
|
|
738
|
-
filterV9Deprecation = createCheckV9Deprecation(['firestore', 'Filter']);
|
|
739
|
-
persistentCacheIndexManagerV9Deprecation = createCheckV9Deprecation([
|
|
740
|
-
'firestore',
|
|
741
|
-
'FirestorePersistentCacheIndexManager',
|
|
742
|
-
]);
|
|
743
|
-
|
|
744
|
-
staticsV9Deprecation = createCheckV9Deprecation(['firestore', 'statics']);
|
|
745
|
-
|
|
746
|
-
timestampV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreTimestamp']);
|
|
747
|
-
|
|
748
|
-
// @ts-ignore test
|
|
749
|
-
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
|
|
750
|
-
return new Proxy(
|
|
751
|
-
{},
|
|
752
|
-
{
|
|
753
|
-
get: () =>
|
|
754
|
-
jest.fn().mockResolvedValue({
|
|
755
|
-
source: 'cache',
|
|
756
|
-
changes: [],
|
|
757
|
-
documents: [],
|
|
758
|
-
metadata: {},
|
|
759
|
-
path: 'foo',
|
|
760
|
-
} as never),
|
|
761
|
-
},
|
|
762
|
-
);
|
|
763
|
-
});
|
|
764
|
-
|
|
765
|
-
jest
|
|
766
|
-
.spyOn(FirestoreQuery.prototype, '_handleQueryCursor')
|
|
767
|
-
// @ts-ignore test
|
|
768
|
-
.mockImplementation(() => {
|
|
769
|
-
return [];
|
|
770
|
-
});
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
describe('Firestore', function () {
|
|
774
|
-
it('firestore.batch()', function () {
|
|
775
|
-
const firestore = getFirestore();
|
|
776
|
-
firestoreRefV9Deprecation(
|
|
777
|
-
() => writeBatch(firestore),
|
|
778
|
-
() => firestore.batch(),
|
|
779
|
-
'batch',
|
|
780
|
-
);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
it('firestore.loadBundle()', function () {
|
|
784
|
-
const firestore = getFirestore();
|
|
785
|
-
firestoreRefV9Deprecation(
|
|
786
|
-
() => loadBundle(firestore, 'some bundle'),
|
|
787
|
-
() => firestore.loadBundle('some bundle'),
|
|
788
|
-
'loadBundle',
|
|
789
|
-
);
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
it('firestore.namedQuery()', function () {
|
|
793
|
-
const firestore = getFirestore();
|
|
794
|
-
firestoreRefV9Deprecation(
|
|
795
|
-
() => namedQuery(firestore, 'some name'),
|
|
796
|
-
() => firestore.namedQuery('some name'),
|
|
797
|
-
'namedQuery',
|
|
798
|
-
);
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
it('firestore.clearPersistence()', function () {
|
|
802
|
-
const firestore = getFirestore();
|
|
803
|
-
firestoreRefV9Deprecation(
|
|
804
|
-
() => clearIndexedDbPersistence(firestore),
|
|
805
|
-
() => firestore.clearPersistence(),
|
|
806
|
-
'clearPersistence',
|
|
807
|
-
);
|
|
808
|
-
// Deprecating the modular method clearPersistence() as it doesn't exist on firebase-js-sdk
|
|
809
|
-
firestoreRefV9Deprecation(
|
|
810
|
-
() => clearIndexedDbPersistence(firestore),
|
|
811
|
-
() => clearPersistence(firestore),
|
|
812
|
-
'clearPersistence',
|
|
813
|
-
);
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
it('firestore.waitForPendingWrites()', function () {
|
|
817
|
-
const firestore = getFirestore();
|
|
818
|
-
firestoreRefV9Deprecation(
|
|
819
|
-
() => waitForPendingWrites(firestore),
|
|
820
|
-
() => firestore.waitForPendingWrites(),
|
|
821
|
-
'waitForPendingWrites',
|
|
822
|
-
);
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
it('firestore.terminate()', function () {
|
|
826
|
-
const firestore = getFirestore();
|
|
827
|
-
firestoreRefV9Deprecation(
|
|
828
|
-
() => terminate(firestore),
|
|
829
|
-
() => firestore.terminate(),
|
|
830
|
-
'terminate',
|
|
831
|
-
);
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
it('firestore.useEmulator()', function () {
|
|
835
|
-
const firestore = getFirestore();
|
|
836
|
-
firestoreRefV9Deprecation(
|
|
837
|
-
() => connectFirestoreEmulator(firestore, 'localhost', 8080),
|
|
838
|
-
() => firestore.useEmulator('localhost', 8080),
|
|
839
|
-
'useEmulator',
|
|
840
|
-
);
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
it('firestore.collection()', function () {
|
|
844
|
-
const firestore = getFirestore();
|
|
845
|
-
firestoreRefV9Deprecation(
|
|
846
|
-
() => collection(firestore, 'collection'),
|
|
847
|
-
() => firestore.collection('collection'),
|
|
848
|
-
'collection',
|
|
849
|
-
);
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
it('firestore.collectionGroup()', function () {
|
|
853
|
-
const firestore = getFirestore();
|
|
854
|
-
firestoreRefV9Deprecation(
|
|
855
|
-
() => collectionGroup(firestore, 'collection'),
|
|
856
|
-
() => firestore.collectionGroup('collection'),
|
|
857
|
-
'collectionGroup',
|
|
858
|
-
);
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
it('firestore.disableNetwork()', function () {
|
|
862
|
-
const firestore = getFirestore();
|
|
863
|
-
firestoreRefV9Deprecation(
|
|
864
|
-
() => disableNetwork(firestore),
|
|
865
|
-
() => firestore.disableNetwork(),
|
|
866
|
-
'disableNetwork',
|
|
867
|
-
);
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
it('firestore.doc()', function () {
|
|
871
|
-
const firestore = getFirestore();
|
|
872
|
-
firestoreRefV9Deprecation(
|
|
873
|
-
() => doc(firestore, 'collection/path'),
|
|
874
|
-
() => firestore.doc('collection/path'),
|
|
875
|
-
'doc',
|
|
876
|
-
);
|
|
877
|
-
});
|
|
878
|
-
|
|
879
|
-
it('firestore.enableNetwork()', function () {
|
|
880
|
-
const firestore = getFirestore();
|
|
881
|
-
firestoreRefV9Deprecation(
|
|
882
|
-
() => enableNetwork(firestore),
|
|
883
|
-
() => firestore.enableNetwork(),
|
|
884
|
-
'enableNetwork',
|
|
885
|
-
);
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
it('firestore.runTransaction()', function () {
|
|
889
|
-
const firestore = getFirestore();
|
|
890
|
-
firestoreRefV9Deprecation(
|
|
891
|
-
() => runTransaction(firestore, async () => {}),
|
|
892
|
-
() => firestore.runTransaction(async () => {}),
|
|
893
|
-
'runTransaction',
|
|
894
|
-
);
|
|
895
|
-
});
|
|
896
|
-
|
|
897
|
-
it('firestore.settings()', function () {
|
|
898
|
-
const firestore = getFirestore();
|
|
899
|
-
firestoreRefV9Deprecation(
|
|
900
|
-
// no equivalent settings method for firebase-js-sdk
|
|
901
|
-
() => initializeFirestore(getApp(), {}),
|
|
902
|
-
() => firestore.settings({}),
|
|
903
|
-
'settings',
|
|
904
|
-
);
|
|
905
|
-
});
|
|
906
|
-
});
|
|
907
|
-
|
|
908
|
-
describe('CollectionReference', function () {
|
|
909
|
-
it('CollectionReference.count()', function () {
|
|
910
|
-
const firestore = getFirestore();
|
|
911
|
-
|
|
912
|
-
const query = collection(firestore, 'test');
|
|
913
|
-
|
|
914
|
-
collectionRefV9Deprecation(
|
|
915
|
-
() => getCountFromServer(query),
|
|
916
|
-
() => query.count(),
|
|
917
|
-
'count',
|
|
918
|
-
);
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
it('CollectionReference.countFromServer()', function () {
|
|
922
|
-
const firestore = getFirestore();
|
|
923
|
-
|
|
924
|
-
const query = collection(firestore, 'test');
|
|
925
|
-
|
|
926
|
-
collectionRefV9Deprecation(
|
|
927
|
-
() => getCountFromServer(query),
|
|
928
|
-
() => query.countFromServer(),
|
|
929
|
-
'count',
|
|
930
|
-
);
|
|
931
|
-
});
|
|
932
|
-
|
|
933
|
-
it('CollectionReference.endAt()', function () {
|
|
934
|
-
const firestore = getFirestore();
|
|
935
|
-
|
|
936
|
-
const query = collection(firestore, 'test');
|
|
937
|
-
|
|
938
|
-
collectionRefV9Deprecation(
|
|
939
|
-
() => endAt('foo'),
|
|
940
|
-
() => query.endAt('foo'),
|
|
941
|
-
'endAt',
|
|
942
|
-
);
|
|
943
|
-
});
|
|
944
|
-
|
|
945
|
-
it('CollectionReference.endBefore()', function () {
|
|
946
|
-
const firestore = getFirestore();
|
|
947
|
-
|
|
948
|
-
const query = collection(firestore, 'test');
|
|
949
|
-
|
|
950
|
-
collectionRefV9Deprecation(
|
|
951
|
-
() => endBefore('foo'),
|
|
952
|
-
() => query.endBefore('foo'),
|
|
953
|
-
'endBefore',
|
|
954
|
-
);
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
it('CollectionReference.get()', function () {
|
|
958
|
-
const firestore = getFirestore();
|
|
959
|
-
|
|
960
|
-
const query = collection(firestore, 'test');
|
|
961
|
-
|
|
962
|
-
collectionRefV9Deprecation(
|
|
963
|
-
() => getDocs(query),
|
|
964
|
-
() => query.get(),
|
|
965
|
-
'get',
|
|
966
|
-
);
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
it('CollectionReference.isEqual()', function () {
|
|
970
|
-
const firestore = getFirestore();
|
|
971
|
-
|
|
972
|
-
const query = collection(firestore, 'test');
|
|
973
|
-
|
|
974
|
-
collectionRefV9Deprecation(
|
|
975
|
-
// no equivalent method
|
|
976
|
-
() => {},
|
|
977
|
-
() => query.isEqual(query),
|
|
978
|
-
'isEqual',
|
|
979
|
-
);
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
it('CollectionReference.limit()', function () {
|
|
983
|
-
const firestore = getFirestore();
|
|
984
|
-
|
|
985
|
-
const query = collection(firestore, 'test');
|
|
986
|
-
|
|
987
|
-
collectionRefV9Deprecation(
|
|
988
|
-
() => limit(9),
|
|
989
|
-
() => query.limit(9),
|
|
990
|
-
'limit',
|
|
991
|
-
);
|
|
992
|
-
});
|
|
993
|
-
|
|
994
|
-
it('CollectionReference.limitToLast()', function () {
|
|
995
|
-
const firestore = getFirestore();
|
|
996
|
-
|
|
997
|
-
const query = collection(firestore, 'test');
|
|
998
|
-
|
|
999
|
-
collectionRefV9Deprecation(
|
|
1000
|
-
() => limitToLast(9),
|
|
1001
|
-
() => query.limitToLast(9),
|
|
1002
|
-
'limitToLast',
|
|
1003
|
-
);
|
|
1004
|
-
});
|
|
1005
|
-
|
|
1006
|
-
it('CollectionReference.onSnapshot()', function () {
|
|
1007
|
-
const firestore = getFirestore();
|
|
1008
|
-
|
|
1009
|
-
const query = collection(firestore, 'test');
|
|
1010
|
-
|
|
1011
|
-
collectionRefV9Deprecation(
|
|
1012
|
-
() => onSnapshot(query, () => {}),
|
|
1013
|
-
() => query.onSnapshot(() => {}),
|
|
1014
|
-
'onSnapshot',
|
|
1015
|
-
);
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
it('CollectionReference.orderBy()', function () {
|
|
1019
|
-
const firestore = getFirestore();
|
|
1020
|
-
|
|
1021
|
-
const query = collection(firestore, 'test');
|
|
1022
|
-
|
|
1023
|
-
collectionRefV9Deprecation(
|
|
1024
|
-
() => orderBy('foo', 'asc'),
|
|
1025
|
-
() => query.orderBy('foo', 'asc'),
|
|
1026
|
-
'orderBy',
|
|
1027
|
-
);
|
|
1028
|
-
});
|
|
1029
|
-
|
|
1030
|
-
it('CollectionReference.startAfter()', function () {
|
|
1031
|
-
const firestore = getFirestore();
|
|
1032
|
-
|
|
1033
|
-
const query = collection(firestore, 'test');
|
|
1034
|
-
|
|
1035
|
-
collectionRefV9Deprecation(
|
|
1036
|
-
() => startAfter('foo'),
|
|
1037
|
-
() => query.startAfter('foo'),
|
|
1038
|
-
'startAfter',
|
|
1039
|
-
);
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1042
|
-
it('CollectionReference.startAt()', function () {
|
|
1043
|
-
const firestore = getFirestore();
|
|
1044
|
-
|
|
1045
|
-
const query = collection(firestore, 'test');
|
|
1046
|
-
|
|
1047
|
-
collectionRefV9Deprecation(
|
|
1048
|
-
() => startAt('foo'),
|
|
1049
|
-
() => query.startAt('foo'),
|
|
1050
|
-
'startAt',
|
|
1051
|
-
);
|
|
1052
|
-
});
|
|
1053
|
-
|
|
1054
|
-
it('CollectionReference.where()', function () {
|
|
1055
|
-
const firestore = getFirestore();
|
|
1056
|
-
|
|
1057
|
-
const query = collection(firestore, 'test');
|
|
1058
|
-
|
|
1059
|
-
collectionRefV9Deprecation(
|
|
1060
|
-
() => where('foo', '==', 'bar'),
|
|
1061
|
-
() => query.where('foo', '==', 'bar'),
|
|
1062
|
-
'where',
|
|
1063
|
-
);
|
|
1064
|
-
});
|
|
1065
|
-
|
|
1066
|
-
it('CollectionReference.add()', function () {
|
|
1067
|
-
const firestore = getFirestore();
|
|
1068
|
-
|
|
1069
|
-
const query = collection(firestore, 'test');
|
|
1070
|
-
|
|
1071
|
-
collectionRefV9Deprecation(
|
|
1072
|
-
() => addDoc(query, { foo: 'bar' }),
|
|
1073
|
-
() => query.add({ foo: 'bar' }),
|
|
1074
|
-
'add',
|
|
1075
|
-
);
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
|
-
it('CollectionReference.doc()', function () {
|
|
1079
|
-
const firestore = getFirestore();
|
|
1080
|
-
|
|
1081
|
-
const query = collection(firestore, 'test');
|
|
1082
|
-
|
|
1083
|
-
collectionRefV9Deprecation(
|
|
1084
|
-
() => doc(query, 'bar'),
|
|
1085
|
-
() => query.doc('foo'),
|
|
1086
|
-
'doc',
|
|
1087
|
-
);
|
|
1088
|
-
});
|
|
1089
|
-
});
|
|
1090
|
-
|
|
1091
|
-
describe('DocumentReference', function () {
|
|
1092
|
-
it('DocumentReference.collection()', function () {
|
|
1093
|
-
const firestore = getFirestore();
|
|
1094
|
-
|
|
1095
|
-
const docRef = firestore.doc('some/foo');
|
|
1096
|
-
|
|
1097
|
-
docRefV9Deprecation(
|
|
1098
|
-
() => collection(firestore, 'bar'),
|
|
1099
|
-
() => docRef.collection('bar'),
|
|
1100
|
-
'collection',
|
|
1101
|
-
);
|
|
1102
|
-
});
|
|
1103
|
-
|
|
1104
|
-
it('DocumentReference.delete()', function () {
|
|
1105
|
-
const firestore = getFirestore();
|
|
1106
|
-
|
|
1107
|
-
const docRef = firestore.doc('some/foo');
|
|
1108
|
-
|
|
1109
|
-
docRefV9Deprecation(
|
|
1110
|
-
() => deleteDoc(docRef),
|
|
1111
|
-
() => docRef.delete(),
|
|
1112
|
-
'delete',
|
|
1113
|
-
);
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
it('DocumentReference.get()', function () {
|
|
1117
|
-
const firestore = getFirestore();
|
|
1118
|
-
|
|
1119
|
-
const docRef = firestore.doc('some/foo');
|
|
1120
|
-
|
|
1121
|
-
docRefV9Deprecation(
|
|
1122
|
-
() => getDoc(docRef),
|
|
1123
|
-
() => docRef.get(),
|
|
1124
|
-
'get',
|
|
1125
|
-
);
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
it('DocumentReference.isEqual()', function () {
|
|
1129
|
-
const firestore = getFirestore();
|
|
1130
|
-
|
|
1131
|
-
const docRef = firestore.doc('some/foo');
|
|
1132
|
-
|
|
1133
|
-
docRefV9Deprecation(
|
|
1134
|
-
// no equivalent method
|
|
1135
|
-
() => {},
|
|
1136
|
-
() => docRef.isEqual(docRef),
|
|
1137
|
-
'isEqual',
|
|
1138
|
-
);
|
|
1139
|
-
});
|
|
1140
|
-
|
|
1141
|
-
it('DocumentReference.onSnapshot()', function () {
|
|
1142
|
-
const firestore = getFirestore();
|
|
1143
|
-
|
|
1144
|
-
const docRef = firestore.doc('some/foo');
|
|
1145
|
-
|
|
1146
|
-
docRefV9Deprecation(
|
|
1147
|
-
() => onSnapshot(docRef, () => {}),
|
|
1148
|
-
() => docRef.onSnapshot(() => {}),
|
|
1149
|
-
'onSnapshot',
|
|
1150
|
-
);
|
|
1151
|
-
});
|
|
1152
|
-
|
|
1153
|
-
it('DocumentReference.set()', function () {
|
|
1154
|
-
const firestore = getFirestore();
|
|
1155
|
-
|
|
1156
|
-
const docRef = firestore.doc('some/foo');
|
|
1157
|
-
|
|
1158
|
-
docRefV9Deprecation(
|
|
1159
|
-
() => setDoc(docRef, { foo: 'bar' }),
|
|
1160
|
-
() => docRef.set({ foo: 'bar' }),
|
|
1161
|
-
'set',
|
|
1162
|
-
);
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
it('DocumentReference.update()', function () {
|
|
1166
|
-
const firestore = getFirestore();
|
|
1167
|
-
|
|
1168
|
-
const docRef = firestore.doc('some/foo');
|
|
1169
|
-
|
|
1170
|
-
docRefV9Deprecation(
|
|
1171
|
-
() => updateDoc(docRef, { foo: 'bar' }),
|
|
1172
|
-
() => docRef.update({ foo: 'bar' }),
|
|
1173
|
-
'update',
|
|
1174
|
-
);
|
|
1175
|
-
});
|
|
1176
|
-
});
|
|
1177
|
-
|
|
1178
|
-
it('FirestoreDocumentSnapshot.isEqual()', function () {
|
|
1179
|
-
const firestore = getFirestore();
|
|
1180
|
-
// Every `FirestoreDocumentSnapshot` has been wrapped in deprecation proxy, so we use constructor directly
|
|
1181
|
-
// for ease of mocking
|
|
1182
|
-
const snapshot = createDeprecationProxy(
|
|
1183
|
-
new FirestoreDocumentSnapshot(firestore, {
|
|
1184
|
-
source: 'cache',
|
|
1185
|
-
changes: [],
|
|
1186
|
-
documents: [],
|
|
1187
|
-
metadata: {},
|
|
1188
|
-
path: 'foo',
|
|
1189
|
-
}),
|
|
1190
|
-
);
|
|
1191
|
-
|
|
1192
|
-
docRefV9Deprecation(
|
|
1193
|
-
// no equivalent method
|
|
1194
|
-
() => {},
|
|
1195
|
-
() => snapshot.isEqual(snapshot),
|
|
1196
|
-
'isEqual',
|
|
1197
|
-
);
|
|
1198
|
-
});
|
|
1199
|
-
|
|
1200
|
-
describe('FieldValue', function () {
|
|
1201
|
-
it('FieldValue.delete()', function () {
|
|
1202
|
-
const fieldValue = firestore.FieldValue;
|
|
1203
|
-
fieldValueV9Deprecation(
|
|
1204
|
-
() => deleteField(),
|
|
1205
|
-
() => fieldValue.delete(),
|
|
1206
|
-
'delete',
|
|
1207
|
-
);
|
|
1208
|
-
});
|
|
1209
|
-
|
|
1210
|
-
it('FieldValue.increment()', function () {
|
|
1211
|
-
const fieldValue = firestore.FieldValue;
|
|
1212
|
-
fieldValueV9Deprecation(
|
|
1213
|
-
() => increment(3),
|
|
1214
|
-
() => fieldValue.increment(4),
|
|
1215
|
-
'increment',
|
|
1216
|
-
);
|
|
1217
|
-
});
|
|
1218
|
-
|
|
1219
|
-
it('FieldValue.serverTimestamp()', function () {
|
|
1220
|
-
const fieldValue = firestore.FieldValue;
|
|
1221
|
-
fieldValueV9Deprecation(
|
|
1222
|
-
() => serverTimestamp(),
|
|
1223
|
-
() => fieldValue.serverTimestamp(),
|
|
1224
|
-
'serverTimestamp',
|
|
1225
|
-
);
|
|
1226
|
-
});
|
|
1227
|
-
|
|
1228
|
-
it('FieldValue.arrayUnion()', function () {
|
|
1229
|
-
const fieldValue = firestore.FieldValue;
|
|
1230
|
-
fieldValueV9Deprecation(
|
|
1231
|
-
() => arrayUnion('foo'),
|
|
1232
|
-
() => fieldValue.arrayUnion('bar'),
|
|
1233
|
-
'arrayUnion',
|
|
1234
|
-
);
|
|
1235
|
-
});
|
|
1236
|
-
|
|
1237
|
-
it('FieldValue.arrayRemove()', function () {
|
|
1238
|
-
const fieldValue = firestore.FieldValue;
|
|
1239
|
-
fieldValueV9Deprecation(
|
|
1240
|
-
() => arrayRemove('foo'),
|
|
1241
|
-
() => fieldValue.arrayRemove('bar'),
|
|
1242
|
-
'arrayRemove',
|
|
1243
|
-
);
|
|
1244
|
-
});
|
|
1245
|
-
});
|
|
1246
|
-
|
|
1247
|
-
describe('statics', function () {
|
|
1248
|
-
it('Firestore.setLogLevel()', function () {
|
|
1249
|
-
// @ts-ignore test
|
|
1250
|
-
jest
|
|
1251
|
-
.spyOn(nativeModule, 'getReactNativeModule')
|
|
1252
|
-
.mockReturnValue({ setLogLevel: jest.fn() });
|
|
1253
|
-
|
|
1254
|
-
staticsV9Deprecation(
|
|
1255
|
-
() => setLogLevel('debug'),
|
|
1256
|
-
() => firestore.setLogLevel('debug'),
|
|
1257
|
-
'setLogLevel',
|
|
1258
|
-
);
|
|
1259
|
-
});
|
|
1260
|
-
|
|
1261
|
-
it('Filter static', function () {
|
|
1262
|
-
staticsV9Deprecation(
|
|
1263
|
-
// no corresponding method
|
|
1264
|
-
() => {},
|
|
1265
|
-
() => firestore.Filter,
|
|
1266
|
-
'Filter',
|
|
1267
|
-
);
|
|
1268
|
-
});
|
|
1269
|
-
|
|
1270
|
-
it('Timestamp static', function () {
|
|
1271
|
-
staticsV9Deprecation(
|
|
1272
|
-
() => Timestamp,
|
|
1273
|
-
() => firestore.Timestamp,
|
|
1274
|
-
'Timestamp',
|
|
1275
|
-
);
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
|
-
it('FieldValue static', function () {
|
|
1279
|
-
staticsV9Deprecation(
|
|
1280
|
-
() => FieldValue,
|
|
1281
|
-
() => firestore.FieldValue,
|
|
1282
|
-
'FieldValue',
|
|
1283
|
-
);
|
|
1284
|
-
});
|
|
1285
|
-
|
|
1286
|
-
it('GeoPoint static', function () {
|
|
1287
|
-
staticsV9Deprecation(
|
|
1288
|
-
() => GeoPoint,
|
|
1289
|
-
() => firestore.GeoPoint,
|
|
1290
|
-
'GeoPoint',
|
|
1291
|
-
);
|
|
1292
|
-
});
|
|
1293
|
-
|
|
1294
|
-
it('Blob static', function () {
|
|
1295
|
-
staticsV9Deprecation(
|
|
1296
|
-
() => Blob,
|
|
1297
|
-
() => firestore.Blob,
|
|
1298
|
-
'Blob',
|
|
1299
|
-
);
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
it('FieldPath static', function () {
|
|
1303
|
-
staticsV9Deprecation(
|
|
1304
|
-
() => FieldPath,
|
|
1305
|
-
() => firestore.FieldPath,
|
|
1306
|
-
'FieldPath',
|
|
1307
|
-
);
|
|
1308
|
-
});
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
describe('Filter', function () {
|
|
1312
|
-
it('Filter.or()', function () {
|
|
1313
|
-
const filter = firestore.Filter;
|
|
1314
|
-
filterV9Deprecation(
|
|
1315
|
-
() => or(where('foo.bar', '==', null), where('foo.bar', '==', null)),
|
|
1316
|
-
() => filter.or(filter('foo', '==', 'bar'), filter('baz', '==', 'qux')),
|
|
1317
|
-
'or',
|
|
1318
|
-
);
|
|
1319
|
-
});
|
|
1320
|
-
|
|
1321
|
-
it('Filter.and()', function () {
|
|
1322
|
-
const filter = firestore.Filter;
|
|
1323
|
-
filterV9Deprecation(
|
|
1324
|
-
() => and(where('foo.bar', '==', null), where('foo.bar', '==', null)),
|
|
1325
|
-
() => filter.and(filter('foo', '==', 'bar'), filter('baz', '==', 'qux')),
|
|
1326
|
-
'and',
|
|
1327
|
-
);
|
|
1328
|
-
});
|
|
1329
|
-
});
|
|
1330
|
-
|
|
1331
|
-
describe('FirestorePersistentCacheIndexManager', function () {
|
|
1332
|
-
it('firestore.persistentCacheIndexManager()', function () {
|
|
1333
|
-
const firestore = getFirestore();
|
|
1334
|
-
|
|
1335
|
-
firestoreRefV9Deprecation(
|
|
1336
|
-
() => getPersistentCacheIndexManager(firestore),
|
|
1337
|
-
() => firestore.persistentCacheIndexManager(),
|
|
1338
|
-
'persistentCacheIndexManager',
|
|
1339
|
-
);
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
it('FirestorePersistentCacheIndexManager.enableIndexAutoCreation()', function () {
|
|
1343
|
-
const firestore = getFirestore();
|
|
1344
|
-
// @ts-ignore test
|
|
1345
|
-
firestore._settings.persistence = true;
|
|
1346
|
-
const indexManager = firestore.persistentCacheIndexManager();
|
|
1347
|
-
persistentCacheIndexManagerV9Deprecation(
|
|
1348
|
-
() => enablePersistentCacheIndexAutoCreation(indexManager!),
|
|
1349
|
-
() => indexManager!.enableIndexAutoCreation(),
|
|
1350
|
-
'enableIndexAutoCreation',
|
|
1351
|
-
);
|
|
1352
|
-
});
|
|
1353
|
-
|
|
1354
|
-
it('FirestorePersistentCacheIndexManager.disableIndexAutoCreation()', function () {
|
|
1355
|
-
const firestore = getFirestore();
|
|
1356
|
-
// @ts-ignore test
|
|
1357
|
-
firestore._settings.persistence = true;
|
|
1358
|
-
const indexManager = firestore.persistentCacheIndexManager();
|
|
1359
|
-
persistentCacheIndexManagerV9Deprecation(
|
|
1360
|
-
() => disablePersistentCacheIndexAutoCreation(indexManager!),
|
|
1361
|
-
() => indexManager!.disableIndexAutoCreation(),
|
|
1362
|
-
'disableIndexAutoCreation',
|
|
1363
|
-
);
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
it('FirestorePersistentCacheIndexManager.deleteAllIndexes()', function () {
|
|
1367
|
-
const firestore = getFirestore();
|
|
1368
|
-
// @ts-ignore test
|
|
1369
|
-
firestore._settings.persistence = true;
|
|
1370
|
-
const indexManager = firestore.persistentCacheIndexManager();
|
|
1371
|
-
persistentCacheIndexManagerV9Deprecation(
|
|
1372
|
-
() => deleteAllPersistentCacheIndexes(indexManager!),
|
|
1373
|
-
() => indexManager!.deleteAllIndexes(),
|
|
1374
|
-
'deleteAllIndexes',
|
|
1375
|
-
);
|
|
1376
|
-
});
|
|
1377
|
-
});
|
|
1378
|
-
|
|
1379
|
-
describe('Timestamp', function () {
|
|
1380
|
-
it('Timestamp.seconds', function () {
|
|
1381
|
-
const timestamp = new firestore.Timestamp(2, 3);
|
|
1382
|
-
timestampV9Deprecation(
|
|
1383
|
-
// no corresponding method
|
|
1384
|
-
() => {},
|
|
1385
|
-
() => timestamp.seconds,
|
|
1386
|
-
'seconds',
|
|
1387
|
-
);
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
it('Timestamp.nanoseconds', function () {
|
|
1391
|
-
const timestamp = new firestore.Timestamp(2000, 3000000);
|
|
1392
|
-
timestampV9Deprecation(
|
|
1393
|
-
// no corresponding method
|
|
1394
|
-
() => {},
|
|
1395
|
-
() => timestamp.nanoseconds,
|
|
1396
|
-
'nanoseconds',
|
|
1397
|
-
);
|
|
1398
|
-
});
|
|
1399
|
-
});
|
|
1400
|
-
});
|
|
1401
|
-
});
|