Skip to content

Commit

Permalink
updated tests exercising fix for issue 931
Browse files Browse the repository at this point in the history
  • Loading branch information
treygriffith authored and aheckmann committed Jun 15, 2012
1 parent 654f5d4 commit 42b9ee0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/model.findAndUpdateOne.test.js
Expand Up @@ -342,6 +342,26 @@ module.exports = {
}
},

'findOneAndUpdate executes when a callback is passed to a succeeding function': function() {
var db = start()
, M = db.model(modelname, collection + random())
, pending = 6

M.findOneAndUpdate({ name: 'aaron' }, { $set: { name: 'Aaron'}}, { new: false }).exec(done);
M.findOneAndUpdate({ name: 'aaron' }, { $set: { name: 'Aaron'}}).exec(done);
M.where().findOneAndUpdate({ name: 'aaron' }, { $set: { name: 'Aaron'}}, { new: false }).exec(done);
M.where().findOneAndUpdate({ name: 'aaron' }, { $set: { name: 'Aaron'}}).exec(done);
M.where().findOneAndUpdate({ $set: { name: 'Aaron'}}).exec(done);
M.where('name', 'aaron').findOneAndUpdate({ $set: { name: 'Aaron'}}).exec(done);

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

'Model.findOneAndUpdate(callback) throws': function () {
var db = start()
, M = db.model(modelname, collection)
Expand Down

0 comments on commit 42b9ee0

Please sign in to comment.