From 3d506c24bdfa4672d74276680f69a18e62c466bc Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Thu, 23 May 2013 17:04:39 +0200 Subject: [PATCH] Tested that node errors are returned for badly formed queries --- test/db.test.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/db.test.js b/test/db.test.js index aa5ac1e..b3084bb 100644 --- a/test/db.test.js +++ b/test/db.test.js @@ -313,6 +313,22 @@ describe('Database', function () { }); }); + it('Returns an error if the query is not well formed', function (done) { + d.insert({ hello: 'world' }, function () { + d.find({ $or: { hello: 'world' } }, function (err, docs) { + assert.isDefined(err); + assert.isUndefined(docs); + + d.findOne({ $or: { hello: 'world' } }, function (err, doc) { + assert.isDefined(err); + assert.isUndefined(doc); + + done(); + }); + }); + }); + }); + }); // ==== End of 'Find' ==== // @@ -586,6 +602,18 @@ describe('Database', function () { }); }); + it('Returns an error if the query is not well formed', function (done) { + d.insert({ hello: 'world' }, function () { + d.update({ $or: { hello: 'world' } }, { a: 1 }, {}, function (err, nr, upsert) { + assert.isDefined(err); + assert.isUndefined(nr); + assert.isUndefined(upsert); + + done(); + }); + }); + }); + }); // ==== End of 'Update' ==== // @@ -661,6 +689,18 @@ describe('Database', function () { }); }); + it('Returns an error if the query is not well formed', function (done) { + d.insert({ hello: 'world' }, function () { + d.remove({ $or: { hello: 'world' } }, {}, function (err, nr, upsert) { + assert.isDefined(err); + assert.isUndefined(nr); + assert.isUndefined(upsert); + + done(); + }); + }); + }); + }); // ==== End of 'Remove' ==== //