Skip to content

Commit 8154c4b

Browse files
committed
Add a spec test that shows correct global resume token handling
1 parent 8309eb3 commit 8154c4b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/firestore/test/unit/specs/listen_spec.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,30 @@ describeSpec('Listens:', [], () => {
509509
.watchAcksFull(query, 3000)
510510
.expectEvents(query, {});
511511
});
512+
513+
specTest('Persists global resume tokens', [], () => {
514+
const query = Query.atPath(path('collection'));
515+
const docA = doc('collection/a', 1000, { key: 'a' });
516+
517+
return (
518+
spec()
519+
.withGCEnabled(false)
520+
.userListens(query)
521+
.watchAcksFull(query, 1000, docA)
522+
.expectEvents(query, { added: [docA] })
523+
524+
// Some time later, watch sends an updated resume token and the user stops
525+
// listening.
526+
.watchSnapshots(2000, [], 'resume-token-2000')
527+
.userUnlistens(query)
528+
.watchRemoves(query)
529+
530+
.userListens(query, 'resume-token-2000')
531+
.expectEvents(query, { added: [docA], fromCache: true })
532+
.watchAcks(query)
533+
.watchCurrents(query, 'resume-token-3000')
534+
.watchSnapshots(3000)
535+
.expectEvents(query, { fromCache: false })
536+
);
537+
});
512538
});

0 commit comments

Comments
 (0)