Update _.result to execute default values if they're functions.

This commit is contained in:
John-David Dalton
2014-12-10 23:28:32 -08:00
parent 94fd20e864
commit cd5f9b8bd4
2 changed files with 16 additions and 14 deletions

View File

@@ -10374,7 +10374,7 @@
});
test('should return the specified default value for undefined properties', 1, function() {
var values = empties.concat(true, new Date, _.constant(1), 1, /x/, 'a');
var values = empties.concat(true, new Date, 1, /x/, 'a');
var expected = _.transform(values, function(result, value) {
result.push(value, value);
@@ -10389,6 +10389,11 @@
deepEqual(actual, expected);
});
test('should execute default function values', 1, function() {
var actual = _.result(object, 'd', object.c);
strictEqual(actual, 1);
});
}());
/*--------------------------------------------------------------------------*/