Skip to content

document_overlay_cache.test.ts: added a test for updating a document's overlay #6015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/firestore/test/unit/local/document_overlay_cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,22 @@ function genericDocumentOverlayCacheTests(): void {
);
verifyOverlayContains(overlays, 'coll/doc1', 'coll/doc2', 'coll/doc3');
});

it('updating an overlay removes the old entry for that overlay', async () => {
const m1 = patchMutation('coll/doc', { 'foo': '1' });
const m2 = patchMutation('coll/doc', { 'foo': '2' });
await saveOverlaysForMutations(1, m1);
await saveOverlaysForMutations(2, m2);

// Verify that `getOverlay()` returns the updated mutation.
const overlay = await overlayCache.getOverlay(key('coll/doc'));
verifyEqualMutations(overlay!.mutation, m2);

// Verify that `removeOverlaysForBatchId()` removes the overlay completely.
await overlayCache.removeOverlaysForBatchId(
documentKeySet(key('coll/doc')),
2
);
expect(await overlayCache.getOverlay(key('coll/doc'))).to.equal(null);
});
}