summaryrefslogtreecommitdiff
path: root/mocha_test/timeout.js
diff options
context:
space:
mode:
Diffstat (limited to 'mocha_test/timeout.js')
-rw-r--r--mocha_test/timeout.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/mocha_test/timeout.js b/mocha_test/timeout.js
index be41283..cd4a751 100644
--- a/mocha_test/timeout.js
+++ b/mocha_test/timeout.js
@@ -69,4 +69,40 @@ describe('timeout', function () {
done();
});
});
+
+ it('timeout with multiple calls (#1418)', function(done) {
+ var timeout = async.timeout(function asyncFn(n, callback) {
+ if (n < 1) {
+ setTimeout(function() {
+ callback(null, 'I will time out');
+ }, 75);
+ } else {
+ async.setImmediate(function() {
+ callback(null, 'I didn\'t time out');
+ })
+ }
+ }, 50);
+
+ async.series([
+ function(cb) {
+ timeout(0, function(err, result) {
+ expect(err.message).to.equal('Callback function "asyncFn" timed out.');
+ expect(err.code).to.equal('ETIMEDOUT');
+ expect(err.info).to.equal(undefined);
+ expect(result).to.equal(undefined);
+ cb();
+ });
+ },
+ function(cb) {
+ timeout(1, function(err, result) {
+ expect(err).to.equal(null);
+ expect(result).to.equal('I didn\'t time out');
+ cb();
+ });
+ }
+ ], function(err) {
+ expect(err).to.equal(null);
+ done();
+ });
+ })
});