Skip to content

Commit 3a46f68

Browse files
add sinon assertion
1 parent e0b033c commit 3a46f68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/integration/crud/find.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { assert: test } = require('../shared');
33
const { expect } = require('chai');
44
const sinon = require('sinon');
55
const { setTimeout } = require('timers');
6-
const { Code, ObjectId, Long, Binary, ReturnDocument } = require('../../mongodb');
6+
const { Code, ObjectId, Long, Binary, ReturnDocument, CursorResponse } = require('../../mongodb');
77

88
describe('Find', function () {
99
let client;
@@ -2395,13 +2395,19 @@ describe('Find', function () {
23952395
await collection.deleteMany({});
23962396
await collection.insertMany(Array.from({ length: 4 }, (_, i) => ({ x: i })));
23972397

2398+
const getMoreSpy = sinon.spy(CursorResponse, 'emptyGetMore', ['get']);
2399+
23982400
const cursor = collection.find({}, { batchSize: 1, limit: 3 });
23992401
// emptyGetMore is used internally after limit + 1 documents have been iterated
24002402
await cursor.next();
24012403
await cursor.next();
24022404
await cursor.next();
24032405
await cursor.next();
24042406

2407+
// assert that `emptyGetMore` is called. if it is not, this test
2408+
// always passes, even without the fix in NODE-6878.
2409+
expect(getMoreSpy.get).to.have.been.called;
2410+
24052411
cursor.rewind();
24062412

24072413
await cursor.toArray();

0 commit comments

Comments
 (0)