Skip to content

Commit dc039fe

Browse files
committed
Merge branch 'timestamp' into functions
2 parents 6a77ab1 + f614189 commit dc039fe

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

test/unit/firestore-collection.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ describe('MockFirestoreCollection', function () {
382382
}).catch(done);
383383
});
384384

385-
it('returns documents ordered by date', function(done) {
385+
it('returns documents ordered by timestamp', function(done) {
386386
db.collection('group').doc().create({
387387
name: 'a',
388388
date: Timestamp.fromMillis(1000)
@@ -411,6 +411,36 @@ describe('MockFirestoreCollection', function () {
411411
}).catch(done);
412412
db.flush();
413413
});
414+
415+
it('returns documents ordered by date', function(done) {
416+
db.collection('group').doc().create({
417+
name: 'a',
418+
date: new Date(1000)
419+
}).catch(done);
420+
db.flush();
421+
db.collection('group').add({
422+
name: 'b',
423+
date: new Date(2000)
424+
}).catch(done);
425+
db.flush();
426+
427+
db.collection('group').orderBy('date', 'asc').get().then(function (snap) {
428+
expect(snap.size).to.equal(2);
429+
expect(snap.docs[0].data().name).to.equal('a');
430+
expect(snap.docs[0].data().date).to.have.property('seconds');
431+
expect(snap.docs[1].data().name).to.equal('b');
432+
expect(snap.docs[1].data().date).to.have.property('seconds');
433+
434+
db.collection('group').orderBy('date', 'desc').get().then(function (snap) {
435+
expect(snap.size).to.equal(2);
436+
expect(snap.docs[0].data().name).to.equal('b');
437+
expect(snap.docs[1].data().name).to.equal('a');
438+
done();
439+
}).catch(done);
440+
db.flush();
441+
}).catch(done);
442+
db.flush();
443+
});
414444
});
415445

416446
describe('#limit', function () {

0 commit comments

Comments
 (0)