From 01d961bad8a59efc7d55c7e642e64f53dca0713d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 19 Mar 2016 23:30:30 -0700 Subject: [PATCH] Ensure `fp.isEqualWith` rearg is `(c,a,b)`. [closes #2131] --- fp/_mapping.js | 1 + test/test-fp.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fp/_mapping.js b/fp/_mapping.js index a7c4df579..43d21833c 100644 --- a/fp/_mapping.js +++ b/fp/_mapping.js @@ -143,6 +143,7 @@ exports.methodRearg = { 'assignInWith': [1, 2, 0], 'assignWith': [1, 2, 0], 'getOr': [2, 1, 0], + 'isEqualWith': [1, 2, 0], 'isMatchWith': [2, 1, 0], 'mergeWith': [1, 2, 0], 'padChars': [2, 1, 0], diff --git a/test/test-fp.js b/test/test-fp.js index 3ee9d3d44..9eac55c40 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -868,7 +868,7 @@ object = { 'a': 1 }; QUnit.test('should provide the correct `customizer` arguments', function(assert) { - assert.expect(5); + assert.expect(6); var args, value = _.clone(object); @@ -888,11 +888,26 @@ assert.deepEqual(args, [undefined, 2, 'b', { 'a': 1 }, { 'b': 2 }], 'fp.extendWith'); - var stack = { '__data__': { 'array': [], 'map': null } }, - expected = [[1], [2, 3], 'a', { 'a': [1] }, { 'a': [2, 3] }, stack]; + var iteration = 0, + objects = [{ 'a': 1 }, { 'a': 2 }], + stack = { '__data__': { 'array': [[objects[0], objects[1]]], 'map': null } }, + expected = [1, 2, 'a', objects[0], objects[1], stack]; + + args = undefined; + + fp.isEqualWith(function() { + if (++iteration == 2) { + args = _.map(arguments, _.cloneDeep); + } + })(objects[0])(objects[1]); + + args[5] = _.omitBy(args[5], _.isFunction); + assert.deepEqual(args, expected, 'fp.isEqualWith'); args = undefined; value = { 'a': [1] }; + stack = { '__data__': { 'array': [], 'map': null } }; + expected = [[1], [2, 3], 'a', { 'a': [1] }, { 'a': [2, 3] }, stack]; fp.mergeWith(function() { args || (args = _.map(arguments, _.cloneDeep));