Skip to content

Commit

Permalink
test: fix some code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed May 18, 2023
1 parent bb9bc35 commit cc2adec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3410,7 +3410,7 @@ Model.bulkWrite = async function bulkWrite(ops, options) {
results[validOpIndexes[i]] = null;
}
if (validationErrors.length > 0) {
if ('throwOnValidationError' in options && options.throwOnValidationError) {
if (options.throwOnValidationError) {
return reject(new MongooseBulkWriteError(
validationErrors,
results,
Expand Down
3 changes: 3 additions & 0 deletions test/model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6237,6 +6237,9 @@ describe('Model', function() {
assert.equal(err.validationErrors[0].errors['age'].name, 'CastError');
assert.ok(err.results[2] instanceof Error);
assert.equal(err.results[2].errors['age'].name, 'CastError');

const docs = await User.find();
assert.deepStrictEqual(docs.map(doc => doc.age), [12, 12]);
});

it('returns writeResult on success', async() => {
Expand Down

0 comments on commit cc2adec

Please sign in to comment.