Skip to content

Commit 4be6fc8

Browse files
committed
Add test for Firestore Query#stream
1 parent 3dad975 commit 4be6fc8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/unit/firestore-collection.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,37 @@ describe('MockFirestoreCollection', function () {
268268
});
269269
});
270270

271+
describe('#stream', function () {
272+
function makeSnapComparable(snap) {
273+
return {
274+
id: snap.id,
275+
data: snap.data(),
276+
};
277+
}
278+
279+
it('returns a stream that emits all results', function (done) {
280+
collection.get().then(function (snaps) {
281+
var streamDocs = [];
282+
283+
collection.stream()
284+
.on('data', function(snap) {
285+
streamDocs.push(makeSnapComparable(snap));
286+
})
287+
.on('end', function () {
288+
try {
289+
expect(streamDocs).to.eql(snaps.docs.map(makeSnapComparable));
290+
done();
291+
} catch (err) {
292+
done(err);
293+
}
294+
});
295+
296+
db.flush();
297+
}).catch(done);
298+
db.flush();
299+
});
300+
});
301+
271302
describe('#orderBy', function () {
272303
it('allow calling orderBy() on collection', function() {
273304
expect(function() {

0 commit comments

Comments
 (0)