|
2 | 2 | const test = require('./shared').assert;
|
3 | 3 | const setupDatabase = require('./shared').setupDatabase;
|
4 | 4 | const expect = require('chai').expect;
|
| 5 | +const MongoClient = require('../..').MongoClient; |
5 | 6 |
|
6 | 7 | describe('Collection', function() {
|
7 | 8 | before(function() {
|
@@ -1581,6 +1582,40 @@ describe('Collection', function() {
|
1581 | 1582 | }
|
1582 | 1583 | });
|
1583 | 1584 |
|
| 1585 | + it('should correctly perform estimatedDocumentCount on non-matching query', function(done) { |
| 1586 | + const configuration = this.configuration; |
| 1587 | + const client = new MongoClient(configuration.url(), { w: 1 }); |
| 1588 | + |
| 1589 | + client.connect(function(err, client) { |
| 1590 | + const db = client.db(configuration.db); |
| 1591 | + const collection = db.collection('nonexistent_coll_1'); |
| 1592 | + const close = e => client.close(() => done(e)); |
| 1593 | + |
| 1594 | + Promise.resolve() |
| 1595 | + .then(() => collection.estimatedDocumentCount({ a: 'b' })) |
| 1596 | + .then(count => expect(count).to.equal(0)) |
| 1597 | + .then(() => close()) |
| 1598 | + .catch(e => close(e)); |
| 1599 | + }); |
| 1600 | + }); |
| 1601 | + |
| 1602 | + it('should correctly perform countDocuments on non-matching query', function(done) { |
| 1603 | + const configuration = this.configuration; |
| 1604 | + const client = new MongoClient(configuration.url(), { w: 1 }); |
| 1605 | + |
| 1606 | + client.connect(function(err, client) { |
| 1607 | + const db = client.db(configuration.db); |
| 1608 | + const collection = db.collection('nonexistent_coll_2'); |
| 1609 | + const close = e => client.close(() => done(e)); |
| 1610 | + |
| 1611 | + Promise.resolve() |
| 1612 | + .then(() => collection.countDocuments({ a: 'b' })) |
| 1613 | + .then(count => expect(count).to.equal(0)) |
| 1614 | + .then(() => close()) |
| 1615 | + .catch(e => close(e)); |
| 1616 | + }); |
| 1617 | + }); |
| 1618 | + |
1584 | 1619 | describe('Retryable Writes on bulk ops', function() {
|
1585 | 1620 | const MongoClient = require('../../lib/mongo_client');
|
1586 | 1621 |
|
|
0 commit comments