Added tests for falsy callback

See #372
pull/2/head
Félicien FRANCOIS 9 years ago
parent 2e44b8154f
commit 2264600955
  1. 27
      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
@ -131,6 +150,10 @@ describe('Executor', function () {
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);
});
@ -160,6 +183,10 @@ describe('Executor', function () {
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);
});

Loading…
Cancel
Save