Skip to content

Commit c8907fa

Browse files
authored
document_overlay_cache.test.ts: added a test for updating a document's overlay (#6015)
* document_overlay_cache.test.ts: added a test for updating a document's overlay, ported from firebase/firebase-ios-sdk@cf04e67 * document_overlay_cache.test.ts: replace it.only() that was accidentally left in with it()
1 parent 307d019 commit c8907fa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/firestore/test/unit/local/document_overlay_cache.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,22 @@ function genericDocumentOverlayCacheTests(): void {
308308
);
309309
verifyOverlayContains(overlays, 'coll/doc1', 'coll/doc2', 'coll/doc3');
310310
});
311+
312+
it('updating an overlay removes the old entry for that overlay', async () => {
313+
const m1 = patchMutation('coll/doc', { 'foo': '1' });
314+
const m2 = patchMutation('coll/doc', { 'foo': '2' });
315+
await saveOverlaysForMutations(1, m1);
316+
await saveOverlaysForMutations(2, m2);
317+
318+
// Verify that `getOverlay()` returns the updated mutation.
319+
const overlay = await overlayCache.getOverlay(key('coll/doc'));
320+
verifyEqualMutations(overlay!.mutation, m2);
321+
322+
// Verify that `removeOverlaysForBatchId()` removes the overlay completely.
323+
await overlayCache.removeOverlaysForBatchId(
324+
documentKeySet(key('coll/doc')),
325+
2
326+
);
327+
expect(await overlayCache.getOverlay(key('coll/doc'))).to.equal(null);
328+
});
311329
}

0 commit comments

Comments
 (0)