Skip to content

Commit 4d96f6c

Browse files
committed
test: enable / remove skipped tests
Enable tests that seem to work. Remove tests for removed functionality. Enable "mocha/no-pending-tests" lint.
1 parent d9e6a85 commit 4d96f6c

File tree

4 files changed

+9
-42
lines changed

4 files changed

+9
-42
lines changed

test/document.test.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const start = require('./common');
99
const Document = require('../lib/document');
1010
const EventEmitter = require('events').EventEmitter;
1111
const ArraySubdocument = require('../lib/types/arraySubdocument');
12-
const Query = require('../lib/query');
1312
const assert = require('assert');
1413
const idGetter = require('../lib/helpers/schema/idGetter');
1514
const sinon = require('sinon');
@@ -1203,38 +1202,6 @@ describe('document', function() {
12031202
});
12041203
});
12051204

1206-
describe.skip('#update', function() {
1207-
it('returns a Query', function() {
1208-
const mg = new mongoose.Mongoose();
1209-
const M = mg.model('Test', { s: String });
1210-
const doc = new M();
1211-
assert.ok(doc.update() instanceof Query);
1212-
});
1213-
it('calling update on document should relay to its model (gh-794)', async function() {
1214-
const Docs = new Schema({ text: String });
1215-
const docs = db.model('Test', Docs);
1216-
const d = new docs({ text: 'A doc' });
1217-
let called = false;
1218-
await d.save();
1219-
1220-
const oldUpdate = docs.update;
1221-
docs.update = function(query, operation) {
1222-
assert.equal(Object.keys(query).length, 1);
1223-
assert.equal(d._id, query._id);
1224-
assert.equal(Object.keys(operation).length, 1);
1225-
assert.equal(Object.keys(operation.$set).length, 1);
1226-
assert.equal(operation.$set.text, 'A changed doc');
1227-
called = true;
1228-
docs.update = oldUpdate;
1229-
oldUpdate.apply(docs, arguments);
1230-
};
1231-
1232-
await d.update({ $set: { text: 'A changed doc' } });
1233-
1234-
assert.equal(called, true);
1235-
});
1236-
});
1237-
12381205
it('toObject should not set undefined values to null', function() {
12391206
const doc = new TestDocument();
12401207
const obj = doc.toObject();
@@ -10500,8 +10467,9 @@ describe('document', function() {
1050010467
assert.equal(user.init, 12);
1050110468
});
1050210469
});
10503-
xdescribe('Document#collection', () => {
10504-
it('is available as `$collection`', async() => {
10470+
10471+
describe('Document#collection', function() {
10472+
it('is available as `$collection`', async function() {
1050510473
const userSchema = new Schema({ name: String });
1050610474
const User = db.model('User', userSchema);
1050710475

@@ -10754,8 +10722,7 @@ describe('document', function() {
1075410722
});
1075510723

1075610724
// skip until gh-10367 is implemented
10757-
xit('support `pathsToSkip` option for `Model.validate()`', async() => {
10758-
10725+
it.skip('support `pathsToSkip` option for `Model.validate()`', async function() {
1075910726
const User = getUserModel();
1076010727
const err1 = await User.validate({}, { pathsToSkip: ['age'] });
1076110728
assert.deepEqual(Object.keys(err1.errors), ['name']);

test/model.indexes.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ describe('model', function() {
384384
});
385385
});
386386

387-
describe.skip('model.ensureIndexes()', function() {
387+
describe('model.ensureIndexes()', function() {
388388
it('is a function', function() {
389389
const schema = mongoose.Schema({ x: 'string' });
390390
const Test = mongoose.createConnection().model('ensureIndexes-' + random, schema);

test/model.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,6 +3186,7 @@ describe('Model', function() {
31863186

31873187
});
31883188

3189+
// the following causes "MongoServerError: ns not found" errors in mongodb 6.0.x
31893190
it.skip('Compound index with 2dsphere field without value is saved', async function() {
31903191
const PersonSchema = new Schema({
31913192
name: String,
@@ -3217,9 +3218,9 @@ describe('Model', function() {
32173218
assert.equal(personDoc.loc, undefined);
32183219

32193220
await Person.collection.drop();
3220-
32213221
});
32223222

3223+
// the following causes "MongoServerError: ns not found" errors in mongodb 6.0.x
32233224
it.skip('Compound index on field earlier declared with 2dsphere index is saved', async function() {
32243225
const PersonSchema = new Schema({
32253226
name: String,
@@ -3252,7 +3253,6 @@ describe('Model', function() {
32523253
assert.equal(personDoc.loc, undefined);
32533254

32543255
await Person.collection.drop();
3255-
32563256
});
32573257
});
32583258

test/query.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,9 +1498,9 @@ describe('Query', function() {
14981498
then(() => Product.find().sort({ _id: 1 }).countDocuments({}).exec());
14991499
});
15001500

1501-
it.skip('ignores count when passed to sort', function() {
1501+
it('ignores count when passed to sort', function() {
15021502
const Product = db.model('Product', productSchema);
1503-
return Product.find().count({}).sort({ _id: 1 }).exec();
1503+
return Product.find().countDocuments({}).sort({ _id: 1 }).exec();
15041504
});
15051505
});
15061506

0 commit comments

Comments
 (0)