diff --git a/test/test.js b/test/test.js index e2c57d7ef..d5aa249c8 100644 --- a/test/test.js +++ b/test/test.js @@ -4256,6 +4256,12 @@ 'countBy', 'every', 'filter', + 'find', + 'findIndex', + 'findKey', + 'findLast', + 'findLastIndex', + 'findLastKey', 'forEachRight', 'forIn', 'forInRight', @@ -4271,6 +4277,11 @@ 'some' ]; + var arrayMethods = [ + 'findIndex', + 'findLastIndex' + ]; + var collectionMethods = [ 'countBy', 'every', @@ -4306,6 +4317,8 @@ ] var objectMethods = [ + 'findKey', + 'findLastKey', 'forIn', 'forInRight', 'forOwn', @@ -4313,6 +4326,9 @@ ]; var rightMethods = [ + 'findLast', + 'findLastIndex', + 'findLastKey', 'forEachRight', 'forInRight', 'forOwnRight' @@ -4320,6 +4336,12 @@ var unwrappedMethods = [ 'every', + 'find', + 'findIndex', + 'findKey', + 'findLast', + 'findLastIndex', + 'findLastKey', 'max', 'min', 'some' @@ -4361,6 +4383,24 @@ }); }); + _.each(_.difference(methods, objectMethods), function(methodName) { + var array = [1, 2, 3], + func = _[methodName], + isEvery = methodName == 'every'; + + array.a = 1; + + test('`_.' + methodName + '` should not iterate custom properties on arrays', 1, function() { + var keys = []; + func(array, function(value, key) { + keys.push(key); + return isEvery; + }); + + ok(!_.contains(keys, 'a')); + }); + }); + _.each(_.difference(methods, unwrappedMethods), function(methodName) { var array = [1, 2, 3], func = _[methodName]; @@ -4391,7 +4431,7 @@ }); }); - _.each(_.difference(methods, forInMethods), function(methodName) { + _.each(_.difference(methods, arrayMethods, forInMethods), function(methodName) { var array = [1, 2, 3], func = _[methodName];