Skip to content

Commit

Permalink
test(document): repro #9963
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 2, 2021
1 parent aa463e6 commit 91581d5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2519,15 +2519,21 @@ describe('document', function() {
});
});

it('filters out validation on unmodified paths when validateModifiedOnly set (gh-7421)', function(done) {
const testSchema = new Schema({ title: { type: String, required: true }, other: String });
it('filters out validation on unmodified paths when validateModifiedOnly set (gh-7421) (gh-9963)', function(done) {
const testSchema = new Schema({
title: { type: String, required: true },
other: String,
subdocs: [{ name: { type: String, required: true } }]
});

const Test = db.model('Test', testSchema);

Test.create([{}], { validateBeforeSave: false }, function(createError, docs) {
const doc = { subdocs: [{ name: null }, { name: 'test' }] };
Test.create([doc], { validateBeforeSave: false }, function(createError, docs) {
assert.equal(createError, null);
const doc = docs[0];
doc.other = 'something';
doc.subdocs[1].name = 'test2';
assert.equal(doc.validateSync(undefined, { validateModifiedOnly: true }), null);
doc.save({ validateModifiedOnly: true }, function(error) {
assert.equal(error, null);
Expand Down

0 comments on commit 91581d5

Please sign in to comment.