diff --git a/test/test.js b/test/test.js index bd4a4d625..222a66a50 100644 --- a/test/test.js +++ b/test/test.js @@ -2785,15 +2785,20 @@ (function() { var methods = [ + 'countBy', 'every', 'filter', - 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', + 'groupBy', + 'indexBy', 'map', + 'max', + 'min', + 'partition', 'reject', 'some' ]; @@ -2803,6 +2808,26 @@ 'some' ]; + var collectionMethods = [ + 'countBy', + 'every', + 'filter', + 'find', + 'findLast', + 'forEach', + 'forEachRight', + 'groupBy', + 'indexBy', + 'map', + 'max', + 'min', + 'partition', + 'reduce', + 'reduceRight', + 'reject', + 'some' + ]; + var forInMethods = [ 'forIn', 'forInRight' @@ -2914,6 +2939,28 @@ } }); }); + + _.forEach(collectionMethods, function(methodName) { + var func = _[methodName]; + + test('`_.' + methodName + '` should treat objects with lengths of `0` as array-like', 1, function() { + var pass = true; + func({ 'length': 0 }, function() { pass = false; }, 0); + ok(pass); + }); + + test('`_.' + methodName + '` should not treat objects with negative lengths as array-like', 1, function() { + var pass = false; + func({ 'length': -1 }, function() { pass = true; }, 0); + ok(pass); + }); + + test('`_.' + methodName + '` should not treat objects with non-number lengths as array-like', 1, function() { + var pass = false; + func({ 'length': '0' }, function() { pass = true; }, 0); + ok(pass); + }); + }); }()); /*--------------------------------------------------------------------------*/