Skip to content

Commit

Permalink
Added tests for falsy callback
Browse files Browse the repository at this point in the history
  • Loading branch information
felicienfrancois committed Feb 10, 2016
1 parent 2e44b81 commit 2264600
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions test/executor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 2264600

Please sign in to comment.