one more needed upsert test

pull/2/head
Louis Chatriot 10 years ago
parent 99a69a421e
commit 4197c3986b
  1. 18
      test/db.test.js

@ -1020,7 +1020,7 @@ describe('Database', function () {
});
});
it('If the update query contains modifiers, it is applied to the object resulting from removing all operator from the find query', function (done) {
it('If the update query contains modifiers, it is applied to the object resulting from removing all operators from the find query 1', function (done) {
d.update({ $or: [{ a: 4 }, { a: 5 }] }, { $set: { hello: 'world' }, $inc: { bloup: 3 } }, { upsert: true }, function (err) {
d.find({ hello: 'world' }, function (err, docs) {
assert.isNull(err);
@ -1034,6 +1034,22 @@ describe('Database', function () {
});
});
it('If the update query contains modifiers, it is applied to the object resulting from removing all operators from the find query 2', function (done) {
d.update({ $or: [{ a: 4 }, { a: 5 }], cac: 'rrr' }, { $set: { hello: 'world' }, $inc: { bloup: 3 } }, { upsert: true }, function (err) {
d.find({ hello: 'world' }, function (err, docs) {
assert.isNull(err);
docs.length.should.equal(1);
var doc = docs[0];
Object.keys(doc).length.should.equal(4);
doc.cac.should.equal('rrr');
doc.hello.should.equal('world');
doc.bloup.should.equal(3);
done();
});
});
});
}); // ==== End of 'Upserts' ==== //
it('Cannot perform update if the update query is not either registered-modifiers-only or copy-only, or contain badly formatted fields', function (done) {

Loading…
Cancel
Save