assert.throws(function () { comb.chain( asyncAction(1, 100, true), syncAction(1.5), asyncAction(2, 90), syncAction(2.5), asyncAction(3, 80), syncAction(3.5), asyncAction(4, 70), syncAction(4.5), asyncAction(5, 60), syncAction(5.5, true), asyncAction(6, 50) ); });
it.should("catch async errors", function (next) { comb.chain([ asyncAction(1, 100, true), syncAction(1.5), asyncAction(2, 90), syncAction(2.5), asyncAction(3, 80), syncAction(3.5), asyncAction(4, 70), syncAction(4.5), asyncAction(5, 60), syncAction(5.5, true), asyncAction(6, 500) ]).then(next, function (res) { assert.deepEqual(res, "ERROR"); next(); }); });
it.should("return multiple arguments if function callback with multiple args", function (next) { comb.chain([ asyncActionMulti(1, 100), asyncActionMulti(1.5), asyncActionMulti(2, 90), asyncActionMulti(2.5), asyncActionMulti(3, 80), asyncActionMulti(3.5), asyncActionMulti(4, 70), asyncActionMulti(4.5), asyncActionMulti(5, 60), asyncActionMulti(5.5), asyncActionMulti(6, 50) ]).then(function (num, prev) { assert.equal(num, 38.5); assert.equal(prev, 137.5); next(); }, next); });
it.should("execute the items serially", function (next) { comb.chain([ asyncAction(1, 100), syncAction(1.5), asyncAction(2, 90), syncAction(2.5), asyncAction(3, 80), syncAction(3.5), asyncAction(4, 70), syncAction(4.5), asyncAction(5, 60), syncAction(5.5), asyncAction(6, 50) ]).then(function (results, prev) { assert.deepEqual(results, 38.5); assert.isUndefined(prev); next(); }, next); });