From a2617d810c893f79abb246c2a7aa19f8ff4a3a82 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 23 May 2016 08:38:46 -0700 Subject: [PATCH] Add failing tests for #2367. --- test/test.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/test.js b/test/test.js index b63a08c73..b979b622e 100644 --- a/test/test.js +++ b/test/test.js @@ -5814,6 +5814,32 @@ }); }()); + (function() { + var array = [1, 2, 3, 4]; + + var expected = ({ + 'find': [0, 1, 2, 3], + 'findLast': [3, 2, 1, 0], + 'findIndex': [0, 1, 2, 3], + 'findLastIndex': [3, 2, 1, 0] + })[methodName]; + + if (expected != null) { + QUnit.test('`_.' + methodName + '` should pass the index as the second argument for `iteratee`', function(assert) { + assert.expect(1); + + var actual = []; + + func(array, function(n, index) { + actual.push(index); + return false; + }); + + assert.deepEqual(actual, expected); + }); + } + }()); + (function() { var array = [1, 2, 3, 4]; @@ -5900,6 +5926,30 @@ }); } }()); + + (function() { + var expected = ({ + 'find': ['a', 'b', 'c'], + 'findLast': ['c', 'b', 'a'], + 'findKey': ['a', 'b', 'c'], + 'findLastKey': ['c', 'b', 'a'] + })[methodName]; + + if (expected != null) { + QUnit.test('`_.' + methodName + '` should pass the key as the second argument for `iteratee`', function(assert) { + assert.expect(1); + + var actual = []; + + func({ 'a': 1, 'b': 2, 'c': 3 }, function(n, key) { + actual.push(key); + return false; + }); + + assert.deepEqual(actual, expected); + }); + } + }()); }); /*--------------------------------------------------------------------------*/