Skip to content

Commit bfd5385

Browse files
committed
add new tests
1 parent c676991 commit bfd5385

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/integration/crud/find_cursor_methods.test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ describe('Find Cursor', function () {
416416
});
417417

418418
context('when there are documents are not retrieved in the first batch', function () {
419-
it('allows combining iteration modes', async function () {
419+
it('allows combining next() and for await syntax', async function () {
420420
let count = 0;
421421
cursor = collection.find({}, { batchSize: 1 }).map(doc => {
422422
count++;
@@ -432,6 +432,24 @@ describe('Find Cursor', function () {
432432
expect(count).to.equal(2);
433433
});
434434

435+
it.only('allows partial iteration with for await syntax and then calling .next()', async function () {
436+
let count = 0;
437+
cursor = collection.find({}, { batchSize: 2 }).map(doc => {
438+
count++;
439+
return doc;
440+
});
441+
442+
for await (const doc of cursor) {
443+
console.log(doc);
444+
/* empty */
445+
break;
446+
}
447+
448+
await cursor.next();
449+
450+
expect(count).to.equal(2);
451+
});
452+
435453
it('works with next + next() loop', async function () {
436454
let count = 0;
437455
cursor = collection.find({}, { batchSize: 1 }).map(doc => {

0 commit comments

Comments
 (0)