Skip to content

Commit

Permalink
Merge pull request #8693 from AbdelrahmanHafez/refactor-test
Browse files Browse the repository at this point in the history
refactor(model.test): prevent false positive in #8331 test
  • Loading branch information
vkarpov15 committed Mar 20, 2020
2 parents 0b92c8a + 542a99b commit 61b157f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/model.test.js
Expand Up @@ -5540,25 +5540,26 @@ describe('Model', function() {

return co(function*() {
const createdUser = yield User.create({ name: 'Hafez' });
let threw = false;

let err;

try {
yield User.bulkWrite([{
updateOne: {
filter: { _id: createdUser._id }
}
}]);
}
catch (err) {
threw = true;
assert.equal(err.message, 'Must provide an update object.');
catch (_err) {
err = _err;
}
finally {
assert.equal(threw, true);

const userAfterUpdate = yield User.findOne({ _id: createdUser._id });
assert.ok(err);
assert.equal(err.message, 'Must provide an update object.');

assert.equal(userAfterUpdate.name, 'Hafez', 'Document data is not wiped if no update object is provided.');
}
const userAfterUpdate = yield User.findOne({ _id: createdUser._id });

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

0 comments on commit 61b157f

Please sign in to comment.