summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--lib/async.js2
-rwxr-xr-xtest/test-async.js76
3 files changed, 78 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index 0a62fca..e5e14f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,4 +3,5 @@ node_js:
- "0.10"
- "0.12"
- "iojs-v2.1.0"
+sudo: false
after_success: npm run coveralls
diff --git a/lib/async.js b/lib/async.js
index f13639f..f80dbcf 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -592,7 +592,7 @@
acc.times = parseInt(t.times, 10) || DEFAULT_TIMES;
acc.interval = parseInt(t.interval, 10) || DEFAULT_INTERVAL;
} else {
- throw new Error('Unsupported argument type for \'times\': ' + typeof(t));
+ throw new Error('Unsupported argument type for \'times\': ' + typeof t);
}
}
diff --git a/test/test-async.js b/test/test-async.js
index fdb949b..72ef132 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -728,6 +728,19 @@ exports['retry when all attempts succeeds'] = function(test) {
});
};
+exports['retry fails with invalid arguments'] = function(test) {
+ test.throws(function() {
+ async.retry("");
+ });
+ test.throws(function() {
+ async.retry();
+ });
+ test.throws(function() {
+ async.retry(function() {}, 2, function() {});
+ });
+ test.done();
+};
+
exports['retry with interval when all attempts succeeds'] = function(test) {
var times = 3;
var interval = 500;
@@ -2465,6 +2478,19 @@ exports['sortBy inverted'] = function(test){
});
};
+exports['sortBy error'] = function(test){
+ test.expect(1);
+ var error = new Error('asdas');
+ async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){
+ async.setImmediate(function(){
+ callback(error);
+ });
+ }, function(err){
+ test.equal(err, error);
+ test.done();
+ });
+};
+
exports['apply'] = function(test){
test.expect(6);
var fn = function(){
@@ -2943,6 +2969,22 @@ exports['doWhilst callback params'] = function (test) {
);
};
+exports['doWhilst - error'] = function (test) {
+ test.expect(1);
+ var error = new Error('asdas');
+
+ async.doWhilst(
+ function (cb) {
+ cb(error);
+ },
+ function () {},
+ function (err) {
+ test.equal(err, error);
+ test.done();
+ }
+ );
+};
+
exports['during'] = function (test) {
var call_order = [];
@@ -3002,6 +3044,40 @@ exports['doDuring'] = function (test) {
);
};
+exports['doDuring - error test'] = function (test) {
+ test.expect(1);
+ var error = new Error('asdas');
+
+ async.doDuring(
+ function (cb) {
+ cb(error);
+ },
+ function () {},
+ function (err) {
+ test.equal(err, error);
+ test.done();
+ }
+ );
+};
+
+exports['doDuring - error iterator'] = function (test) {
+ test.expect(1);
+ var error = new Error('asdas');
+
+ async.doDuring(
+ function (cb) {
+ cb(null);
+ },
+ function (cb) {
+ cb(error);
+ },
+ function (err) {
+ test.equal(err, error);
+ test.done();
+ }
+ );
+};
+
exports['whilst optional callback'] = function (test) {
var counter = 0;
async.whilst(