From 2264600955d0a7d1b28b96f40f41bd64553e201d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9licien=20FRANCOIS?= Date: Wed, 10 Feb 2016 11:28:55 +0100 Subject: [PATCH] Added tests for falsy callback See #372 --- test/executor.test.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/test/executor.test.js b/test/executor.test.js index 6bd1d23..eda33c8 100755 --- a/test/executor.test.js +++ b/test/executor.test.js @@ -38,6 +38,25 @@ function testThrowInCallback (d, done) { }); } +//Test that if the callback is falsy, the next DB operations will still be executed +function testFalsyCallback (d, done) { + d.insert({ a: 1 }, null); + process.nextTick(function () { + d.update({ a: 1 }, { a: 2 }, {}, null); + process.nextTick(function () { + d.update({ a: 2 }, { a: 1 }, null); + process.nextTick(function () { + d.remove({ a: 2 }, {}, null); + process.nextTick(function () { + d.remove({ a: 2 }, null); + process.nextTick(function () { + d.find({}, done); + }); + }); + }); + }); + }); +} // Test that operations are executed in the right order // We prevent Mocha from catching the exception we throw on purpose by remembering all current handlers, remove them and register them back after test ends @@ -130,7 +149,11 @@ describe('Executor', function () { it('A throw in a callback doesnt prevent execution of next operations', function(done) { testThrowInCallback(d, done); }); - + + it('A falsy callback doesnt prevent execution of next operations', function(done) { + testFalsyCallback(d, done); + }); + it('Operations are executed in the right order', function(done) { testRightOrder(d, done); }); @@ -159,7 +182,11 @@ describe('Executor', function () { it('A throw in a callback doesnt prevent execution of next operations', function(done) { testThrowInCallback(d, done); }); - + + it('A falsy callback doesnt prevent execution of next operations', function(done) { + testFalsyCallback(d, done); + }); + it('Operations are executed in the right order', function(done) { testRightOrder(d, done); });