Skip to content

Commit

Permalink
Add test for Automattic#8331
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Nov 13, 2019
1 parent 6c1dcb2 commit a91dc93
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/model.test.js
Expand Up @@ -5671,6 +5671,34 @@ describe('Model', function() {
then(() => Model.findOne()).
then(doc => assert.equal(doc.nested.name, 'foo'));
});

it('throws an error if no update object is provided (gh-8331)', function() {
const userSchema = new Schema({ name: { type: String, required: true } });
const User = db.model('gh8331', userSchema);

return co(function*() {
const createdUser = yield User.create({ name: 'Hafez' });
let threw = false;
try {
yield User.bulkWrite([{
updateOne: {
filter: { _id: createdUser._id }
}
}]);
}
catch (err) {
threw = true;
assert.equal(err.message, 'Must provide an update object.');
}
finally {
assert.equal(threw, true);

const userAfterUpdate = yield User.findOne({ _id: createdUser._id });

assert.equal(userAfterUpdate.name, 'Hafez', 'Document data is not wiped if no update object is provided.');
}
});
});
});

it('insertMany with Decimal (gh-5190)', function(done) {
Expand Down

0 comments on commit a91dc93

Please sign in to comment.