[firestore] Correctly support dates, geopoints, DocumentSnapshots and other types in startAt, startAfter, etc

This commit is contained in:
Chris Bianca
2017-10-31 22:18:07 +00:00
parent 6ae0049338
commit 270279551a
8 changed files with 102 additions and 42 deletions

View File

@@ -569,6 +569,19 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
);
});
});
it('handles snapshots', async () => {
const collectionSnapshot = await collectionTests.orderBy('foo').get();
return collectionTests.orderBy('foo').endAt(collectionSnapshot.docs[2])
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 3);
should.deepEqual(
querySnapshot.docs.map(doc => doc.data().daz),
[123, 234, 345],
);
});
});
});
context('endBefore', () => {
@@ -607,6 +620,19 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
);
});
});
it('handles snapshots', async () => {
const collectionSnapshot = await collectionTests.orderBy('foo').get();
return collectionTests.orderBy('foo').endBefore(collectionSnapshot.docs[2])
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 2);
should.deepEqual(
querySnapshot.docs.map(doc => doc.data().daz),
[123, 234],
);
});
});
});
context('startAt', () => {
@@ -645,6 +671,19 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
);
});
});
it('handles snapshots', async () => {
const collectionSnapshot = await collectionTests.orderBy('foo').get();
return collectionTests.orderBy('foo').startAt(collectionSnapshot.docs[2])
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 3);
should.deepEqual(
querySnapshot.docs.map(doc => doc.data().daz),
[345, 456, 567],
);
});
});
});
context('startAfter', () => {
@@ -683,6 +722,19 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
);
});
});
it('handles snapshot', async () => {
const collectionSnapshot = await collectionTests.orderBy('foo').get();
return collectionTests.orderBy('foo').startAfter(collectionSnapshot.docs[2])
.get()
.then((querySnapshot) => {
should.equal(querySnapshot.size, 2);
should.deepEqual(
querySnapshot.docs.map(doc => doc.data().daz),
[456, 567],
);
});
});
});
after(() => {