From 69e9c7d0bed4b9f3ade1a2b293dc8385601c4842 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 08:04:39 -0800 Subject: [PATCH] Expand `_.defaults` test for working with `_.reduce`. --- test/test.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index aa44ffa5e..9a798cc2e 100644 --- a/test/test.js +++ b/test/test.js @@ -5712,7 +5712,8 @@ QUnit.module('object assignments'); _.each(['assign', 'defaults', 'merge'], function(methodName) { - var func = _[methodName]; + var func = _[methodName], + isDefaults = methodName == 'defaults'; test('`_.' + methodName + '` should pass thru falsey `object` values', 1, function() { var actual = _.map(falsey, function(value, index) { @@ -5787,8 +5788,11 @@ }); test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() { - var array = [{ 'b': 2 }, { 'c': 3 }]; - deepEqual(_.reduce(array, func, { 'a': 1}), { 'a': 1, 'b': 2, 'c': 3 }); + var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }], + expected = { 'a': 1, 'b': 2, 'c': 3 }; + + expected.a = isDefaults ? 0 : 1; + deepEqual(_.reduce(array, func, { 'a': 0 }), expected); }); test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {