Skip to content

Commit

Permalink
Refactor Automattic#8331 test to prevent false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Mar 20, 2020
1 parent b0de5f6 commit 542a99b
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 542a99b

Please sign in to comment.