Skip to content

Commit 7deaea6

Browse files
committed
fix tests
1 parent ed650e0 commit 7deaea6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lib/mquery.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,10 +1971,8 @@ Query.prototype.countDocuments = function(filter) {
19711971
* @returns the results
19721972
*/
19731973
Query.prototype._countDocuments = async function _countDocuments() {
1974-
const conds = this._conditions,
1975-
options = this._optionsForExec();
1976-
1977-
debug('countDocuments', this._collection.collectionName, conds, options);
1974+
const conds = this._conditions;
1975+
const options = this._optionsForExec();
19781976

19791977
return this._collection.countDocuments(conds, options);
19801978
};

test/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ describe('mquery', function() {
20172017
const n = m.updateOne({ $set: { name: name } }).setOptions({ returnDocument: 'after', includeResultMetadata: true });
20182018
const res = await n.findOneAndUpdate();
20192019
assert.ok(res);
2020-
assert.equal(res.name, name);
2020+
assert.equal(res.value.name, name);
20212021
});
20222022
});
20232023
describe('with 2 args', function() {
@@ -2095,7 +2095,7 @@ describe('mquery', function() {
20952095
it('executes', async() => {
20962096
await col.insertOne({ name: name });
20972097
const m = mquery({ name: name }).collection(col);
2098-
const res = await m.findOneAndRemove();
2098+
const res = await m.findOneAndDelete();
20992099
assert.ok(res);
21002100
assert.equal(name, res.name);
21012101
});
@@ -2117,21 +2117,21 @@ describe('mquery', function() {
21172117
it('conditions + exec', async() => {
21182118
await col.insertOne({ name: name });
21192119
const m = mquery().collection(col);
2120-
const res = await m.findOneAndRemove({ name: name });
2120+
const res = await m.findOneAndDelete({ name: name });
21212121
assert.equal(name, res.name);
21222122
});
21232123
it('query + exec', async() => {
21242124
await col.insertOne({ name: name });
21252125
const n = mquery({ name: name });
21262126
const m = mquery().collection(col);
2127-
const res = await m.findOneAndRemove(n);
2127+
const res = await m.findOneAndDelete(n);
21282128
assert.equal(name, res.name);
21292129
});
21302130
it('conditions + options + exec', async() => {
21312131
name = 'findOneAndDelete + conds + options + cb';
21322132
await col.insertMany([{ name: name }, { name: 'a' }]);
21332133
const m = mquery().collection(col);
2134-
const res = await m.findOneAndRemove({ name: name }, { sort: { name: 1 }, includeResultMetadata: true });
2134+
const res = await m.findOneAndDelete({ name: name }, { sort: { name: 1 }, includeResultMetadata: true });
21352135
assert.ok(res.value);
21362136
assert.equal(name, res.value.name);
21372137
});
@@ -2289,7 +2289,7 @@ describe('mquery', function() {
22892289
const m = mquery().collection(col);
22902290
m.findOneAndUpdate({ name: 'exec', age: 1 }, { $set: { name: 'findOneAndUpdate' } }, { returnDocument: 'after', includeResultMetadata: true });
22912291
const res = await m.exec();
2292-
assert.equal(res.name, 'findOneAndUpdate');
2292+
assert.equal(res.value.name, 'findOneAndUpdate');
22932293
});
22942294
});
22952295

@@ -2300,7 +2300,7 @@ describe('mquery', function() {
23002300
const res = await m.exec();
23012301
assert.equal('exec', res.name);
23022302
assert.equal(2, res.age);
2303-
const num = await mquery().collection(col).count({ name: 'exec' });
2303+
const num = await mquery().collection(col).countDocuments({ name: 'exec' });
23042304
assert.equal(1, num);
23052305
});
23062306
});

0 commit comments

Comments
 (0)