Skip to content

Commit ec16923

Browse files
committed
yarn prettier
1 parent 53a2154 commit ec16923

2 files changed

Lines changed: 96 additions & 102 deletions

File tree

packages/firestore/test/integration/api/array_transforms.test.ts

Lines changed: 63 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -164,79 +164,76 @@ apiDescribe('Array Transforms:', persistence => {
164164
* being enabled so documents remain in the cache after the write.
165165
*/
166166
// eslint-disable-next-line no-restricted-properties
167-
(persistence ? describe : describe.skip)(
168-
'Server Application: ',
169-
() => {
170-
it('set() with no cached base doc', async () => {
171-
await withTestDoc(persistence, async docRef => {
172-
await setDoc(docRef, { array: arrayUnion(1, 2) });
173-
const snapshot = await getDocFromCache(docRef);
174-
expect(snapshot.data()).to.deep.equal({ array: [1, 2] });
175-
});
167+
(persistence ? describe : describe.skip)('Server Application: ', () => {
168+
it('set() with no cached base doc', async () => {
169+
await withTestDoc(persistence, async docRef => {
170+
await setDoc(docRef, { array: arrayUnion(1, 2) });
171+
const snapshot = await getDocFromCache(docRef);
172+
expect(snapshot.data()).to.deep.equal({ array: [1, 2] });
173+
});
174+
});
175+
176+
it('update() with no cached base doc', async () => {
177+
let path: string | null = null;
178+
// Write an initial document in an isolated Firestore instance so it's not
179+
// stored in our cache
180+
await withTestDoc(persistence, async docRef => {
181+
path = docRef.path;
182+
await setDoc(docRef, { array: [42] });
176183
});
177184

178-
it('update() with no cached base doc', async () => {
179-
let path: string | null = null;
180-
// Write an initial document in an isolated Firestore instance so it's not
181-
// stored in our cache
182-
await withTestDoc(persistence, async docRef => {
183-
path = docRef.path;
184-
await setDoc(docRef, { array: [42] });
185-
});
186-
187-
await withTestDb(persistence, async db => {
188-
const docRef = doc(db, path!);
189-
await updateDoc(docRef, { array: arrayUnion(1, 2) });
190-
191-
// Nothing should be cached since it was an update and we had no base
192-
// doc.
193-
let errCaught = false;
194-
try {
195-
await getDocFromCache(docRef);
196-
} catch (err) {
197-
expect((err as FirestoreError).code).to.equal('unavailable');
198-
errCaught = true;
199-
}
200-
expect(errCaught).to.be.true;
201-
});
185+
await withTestDb(persistence, async db => {
186+
const docRef = doc(db, path!);
187+
await updateDoc(docRef, { array: arrayUnion(1, 2) });
188+
189+
// Nothing should be cached since it was an update and we had no base
190+
// doc.
191+
let errCaught = false;
192+
try {
193+
await getDocFromCache(docRef);
194+
} catch (err) {
195+
expect((err as FirestoreError).code).to.equal('unavailable');
196+
errCaught = true;
197+
}
198+
expect(errCaught).to.be.true;
202199
});
200+
});
203201

204-
it('set(..., {merge}) with no cached based doc', async () => {
205-
let path: string | null = null;
206-
// Write an initial document in an isolated Firestore instance so it's not
207-
// stored in our cache
208-
await withTestDoc(persistence, async docRef => {
209-
path = docRef.path;
210-
await setDoc(docRef, { array: [42] });
211-
});
212-
213-
await withTestDb(persistence, async db => {
214-
const docRef = doc(db, path!);
215-
await setDoc(docRef, { array: arrayUnion(1, 2) }, { merge: true });
216-
217-
// Document will be cached but we'll be missing 42.
218-
const snapshot = await getDocFromCache(docRef);
219-
expect(snapshot.data()).to.deep.equal({ array: [1, 2] });
220-
});
202+
it('set(..., {merge}) with no cached based doc', async () => {
203+
let path: string | null = null;
204+
// Write an initial document in an isolated Firestore instance so it's not
205+
// stored in our cache
206+
await withTestDoc(persistence, async docRef => {
207+
path = docRef.path;
208+
await setDoc(docRef, { array: [42] });
221209
});
222210

223-
it('update() with cached base doc using arrayUnion()', async () => {
224-
await withTestDoc(persistence, async docRef => {
225-
await setDoc(docRef, { array: [42] });
226-
await updateDoc(docRef, { array: arrayUnion(1, 2) });
227-
const snapshot = await getDocFromCache(docRef);
228-
expect(snapshot.data()).to.deep.equal({ array: [42, 1, 2] });
229-
});
211+
await withTestDb(persistence, async db => {
212+
const docRef = doc(db, path!);
213+
await setDoc(docRef, { array: arrayUnion(1, 2) }, { merge: true });
214+
215+
// Document will be cached but we'll be missing 42.
216+
const snapshot = await getDocFromCache(docRef);
217+
expect(snapshot.data()).to.deep.equal({ array: [1, 2] });
230218
});
219+
});
231220

232-
it('update() with cached base doc using arrayRemove()', async () => {
233-
await withTestDoc(persistence, async docRef => {
234-
await setDoc(docRef, { array: [42, 1, 2] });
235-
await updateDoc(docRef, { array: arrayRemove(1, 2) });
236-
const snapshot = await getDocFromCache(docRef);
237-
expect(snapshot.data()).to.deep.equal({ array: [42] });
238-
});
221+
it('update() with cached base doc using arrayUnion()', async () => {
222+
await withTestDoc(persistence, async docRef => {
223+
await setDoc(docRef, { array: [42] });
224+
await updateDoc(docRef, { array: arrayUnion(1, 2) });
225+
const snapshot = await getDocFromCache(docRef);
226+
expect(snapshot.data()).to.deep.equal({ array: [42, 1, 2] });
239227
});
240-
}
241-
);
228+
});
229+
230+
it('update() with cached base doc using arrayRemove()', async () => {
231+
await withTestDoc(persistence, async docRef => {
232+
await setDoc(docRef, { array: [42, 1, 2] });
233+
await updateDoc(docRef, { array: arrayRemove(1, 2) });
234+
const snapshot = await getDocFromCache(docRef);
235+
expect(snapshot.data()).to.deep.equal({ array: [42] });
236+
});
237+
});
238+
});
242239
});

packages/firestore/test/integration/api/query.test.ts

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,45 +2027,42 @@ apiDescribe('Queries', persistence => {
20272027

20282028
// Reproduces https://github.com/firebase/firebase-js-sdk/issues/5873
20292029
// eslint-disable-next-line no-restricted-properties
2030-
(persistence ? describe : describe.skip)(
2031-
'Caching empty results',
2032-
() => {
2033-
it('can raise initial snapshot from cache, even if it is empty', () => {
2034-
return withTestCollection(persistence, {}, async coll => {
2035-
const snapshot1 = await getDocs(coll); // Populate the cache.
2036-
expect(snapshot1.metadata.fromCache).to.be.false;
2037-
expect(toDataArray(snapshot1)).to.deep.equal([]); // Precondition check.
2038-
2039-
// Add a snapshot listener whose first event should be raised from cache.
2040-
const storeEvent = new EventsAccumulator<QuerySnapshot>();
2041-
onSnapshot(coll, storeEvent.storeEvent);
2042-
const snapshot2 = await storeEvent.awaitEvent();
2043-
expect(snapshot2.metadata.fromCache).to.be.true;
2044-
expect(toDataArray(snapshot2)).to.deep.equal([]);
2045-
});
2030+
(persistence ? describe : describe.skip)('Caching empty results', () => {
2031+
it('can raise initial snapshot from cache, even if it is empty', () => {
2032+
return withTestCollection(persistence, {}, async coll => {
2033+
const snapshot1 = await getDocs(coll); // Populate the cache.
2034+
expect(snapshot1.metadata.fromCache).to.be.false;
2035+
expect(toDataArray(snapshot1)).to.deep.equal([]); // Precondition check.
2036+
2037+
// Add a snapshot listener whose first event should be raised from cache.
2038+
const storeEvent = new EventsAccumulator<QuerySnapshot>();
2039+
onSnapshot(coll, storeEvent.storeEvent);
2040+
const snapshot2 = await storeEvent.awaitEvent();
2041+
expect(snapshot2.metadata.fromCache).to.be.true;
2042+
expect(toDataArray(snapshot2)).to.deep.equal([]);
20462043
});
2044+
});
20472045

2048-
it('can raise initial snapshot from cache, even if it has become empty', () => {
2049-
const testDocs = {
2050-
a: { key: 'a' }
2051-
};
2052-
return withTestCollection(persistence, testDocs, async coll => {
2053-
// Populate the cache.
2054-
const snapshot1 = await getDocs(coll);
2055-
expect(snapshot1.metadata.fromCache).to.be.false;
2056-
expect(toDataArray(snapshot1)).to.deep.equal([{ key: 'a' }]);
2057-
// Empty the collection.
2058-
void deleteDoc(doc(coll, 'a'));
2059-
2060-
const storeEvent = new EventsAccumulator<QuerySnapshot>();
2061-
onSnapshot(coll, storeEvent.storeEvent);
2062-
const snapshot2 = await storeEvent.awaitEvent();
2063-
expect(snapshot2.metadata.fromCache).to.be.true;
2064-
expect(toDataArray(snapshot2)).to.deep.equal([]);
2065-
});
2046+
it('can raise initial snapshot from cache, even if it has become empty', () => {
2047+
const testDocs = {
2048+
a: { key: 'a' }
2049+
};
2050+
return withTestCollection(persistence, testDocs, async coll => {
2051+
// Populate the cache.
2052+
const snapshot1 = await getDocs(coll);
2053+
expect(snapshot1.metadata.fromCache).to.be.false;
2054+
expect(toDataArray(snapshot1)).to.deep.equal([{ key: 'a' }]);
2055+
// Empty the collection.
2056+
void deleteDoc(doc(coll, 'a'));
2057+
2058+
const storeEvent = new EventsAccumulator<QuerySnapshot>();
2059+
onSnapshot(coll, storeEvent.storeEvent);
2060+
const snapshot2 = await storeEvent.awaitEvent();
2061+
expect(snapshot2.metadata.fromCache).to.be.true;
2062+
expect(toDataArray(snapshot2)).to.deep.equal([]);
20662063
});
2067-
}
2068-
);
2064+
});
2065+
});
20692066

20702067
it('resuming a query should use bloom filter to avoid full requery', async () => {
20712068
// Prepare the names and contents of the 100 documents to create.

0 commit comments

Comments
 (0)