From c49e59a838e67abf9f2b81c1263cbf2b07e9bad8 Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Sun, 31 May 2015 19:32:20 -0700 Subject: [PATCH] add test for #578. Closes #578 --- CHANGELOG.md | 3 ++- test/test-async.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d67c0c42..dc023fb0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ Bug Fixes: - `forever` will no longer stack overflow with a synchronous iterator (#622) - `eachLimit` and others limit functions will stop iterating once an error occurs (#754) - Always pass `null` in callbacks when there is no error (#439) -- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668) +- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668) +- `each` and family will properly handle an empty array (#578) - Doc fixes (#766) diff --git a/test/test-async.js b/test/test-async.js index ded054b86..5b60195e3 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -1371,6 +1371,18 @@ exports['forEachOf empty object'] = function(test){ setTimeout(test.done, 25); }; +exports['forEachOf empty array'] = function(test){ + test.expect(1); + async.forEachOf([], function(value, key, callback){ + test.ok(false, 'iterator should not be called'); + callback(); + }, function(err) { + if (err) throw err; + test.ok(true, 'should call callback'); + }); + setTimeout(test.done, 25); +}; + exports['forEachOf error'] = function(test){ test.expect(1); async.forEachOf({ a: 1, b: 2 }, function(value, key, callback) {