mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Expand _.defaults test for working with _.reduce.
This commit is contained in:
10
test/test.js
10
test/test.js
@@ -5712,7 +5712,8 @@
|
|||||||
QUnit.module('object assignments');
|
QUnit.module('object assignments');
|
||||||
|
|
||||||
_.each(['assign', 'defaults', 'merge'], function(methodName) {
|
_.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() {
|
test('`_.' + methodName + '` should pass thru falsey `object` values', 1, function() {
|
||||||
var actual = _.map(falsey, function(value, index) {
|
var actual = _.map(falsey, function(value, index) {
|
||||||
@@ -5787,8 +5788,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() {
|
test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() {
|
||||||
var array = [{ 'b': 2 }, { 'c': 3 }];
|
var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }],
|
||||||
deepEqual(_.reduce(array, func, { 'a': 1}), { '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() {
|
test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user