-
-
Save xrksudy/6580821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports['forEachSeries'] = function(test){ | |
var args = []; | |
async.forEachSeries([1,3,2], function(x, callback){ | |
setTimeout(function(){ | |
args.push(x); | |
callback(); | |
}, x*25); | |
}, function(err){ | |
test.same(args, [1,3,2]); | |
test.done(); | |
}); | |
}; | |
exports['forEachSeries empty array'] = function(test){ | |
test.expect(1); | |
async.forEachSeries([], function(x, callback){ | |
test.ok(false, 'iterator should not be called'); | |
callback(); | |
}, function(err){ | |
test.ok(true, 'should call callback'); | |
}); | |
setTimeout(test.done, 25); | |
}; | |
exports['forEachSeries error'] = function(test){ | |
test.expect(2); | |
var call_order = []; | |
async.forEachSeries([1,2,3], function(x, callback){ | |
call_order.push(x); | |
callback('error'); | |
}, function(err){ | |
test.same(call_order, [1]); | |
test.equals(err, 'error'); | |
}); | |
setTimeout(test.done, 50); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment