Skip to content

Commit

Permalink
test(model): add coverage for #6972
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 24, 2018
1 parent 05aa04d commit 477e8ca
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/model.findOneAndUpdate.test.js
Expand Up @@ -2226,6 +2226,28 @@ describe('model: findOneAndUpdate:', function() {
const opts = { runValidators: true };
return Model.findOneAndUpdate({}, { $pull: { arr: { x: 'three' } } }, opts);
});

it('$pull with `required` and runValidators (gh-6972)', function() {
const schema = new mongoose.Schema({
someArray: {
type: [{
innerField: {
type: mongoose.Schema.Types.ObjectId,
required: true
}
}]
}
});

return co(function*() {
const Model = db.model('gh6972', schema);
yield Model.findOneAndUpdate({}, {
$pull: {someArray: {innerField: '507f191e810c19729de860ea'}}
}, {
runValidators: true
});
});
});
});

it('with versionKey in top-level and a `$` key (gh-7003)', function() {
Expand Down

0 comments on commit 477e8ca

Please sign in to comment.