Skip to content

Commit

Permalink
updated tests to include findByIdAndUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
treygriffith authored and aheckmann committed Jun 15, 2012
1 parent 42b9ee0 commit 5b0c405
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/model.findAndUpdateOne.test.js
Expand Up @@ -499,6 +499,23 @@ module.exports = {
}
},

'findByIdAndUpdate executes when a callback is passed to a succeeding function': function () {
var db = start()
, M = db.model(modelname, collection + random())
, _id = new DocumentObjectId
, pending = 2

M.findByIdAndUpdate(_id, { $set: { name: 'Aaron'}}, { new: false }).exec(done);
M.findByIdAndUpdate(_id, { $set: { name: 'changed' }}).exec(done);

function done (err, doc) {
should.strictEqual(null, err);
should.strictEqual(null, doc); // no previously existing doc
if (--pending) return;
db.close();
}
},

'findByIdAndUpdate returns the original document': function () {
var db = start()
, M = db.model(modelname, collection)
Expand Down

0 comments on commit 5b0c405

Please sign in to comment.