From ddd4c391a147d20cbc8238c045f0ab3060333235 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 2 Mar 2016 22:25:51 -0800 Subject: [PATCH] Add `_.updateWith` test for a `customizer`. --- test/test.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/test/test.js b/test/test.js index 1705c83fb..f3b032427 100644 --- a/test/test.js +++ b/test/test.js @@ -18471,13 +18471,11 @@ QUnit.test('should work with a `customizer` callback', function(assert) { assert.expect(1); - var actual = _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, function(value) { - if (!lodashStable.isObject(value)) { - return {}; - } + var actual = _.setWith({ '0': {} }, '[0][1][2]', 3, function(value) { + return lodashStable.isObject(value) ? undefined : {}; }); - assert.deepEqual(actual, { '0': { '1': { '2': 3 }, 'length': 2 } }); + assert.deepEqual(actual, { '0': { '1': { '2': 3 } } }); }); QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { @@ -23121,6 +23119,29 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.updateWith'); + + (function() { + QUnit.test('should work with a `customizer` callback', function(assert) { + assert.expect(1); + + var actual = _.updateWith({ '0': {} }, '[0][1][2]', alwaysThree, function(value) { + return lodashStable.isObject(value) ? undefined : {}; + }); + + assert.deepEqual(actual, { '0': { '1': { '2': 3 } } }); + }); + + QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { + assert.expect(1); + + var actual = _.updateWith({}, 'a[0].b.c', alwaysFour, alwaysUndefined); + assert.deepEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('update methods'); lodashStable.each(['update', 'updateWith'], function(methodName) {