Add _.result tests for deep paths.

This commit is contained in:
jdalton
2015-04-03 12:55:42 -05:00
parent 32ef1bb7a5
commit c88589e0e5

View File

@@ -12610,6 +12610,16 @@
strictEqual(_.result(object, 'd'), undefined);
});
test('should get deep property values', 1, function() {
var object = { 'a': { 'b': { 'c': 3 } } };
strictEqual(_.result(object, 'a.b.c'), 3);
});
test('should get a key before treating it as a path', 1, function() {
var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } };
strictEqual(_.result(object, 'a.b.c'), 3);
});
test('should return `undefined` when `object` is nullish', 2, function() {
strictEqual(_.result(null, 'a'), undefined);
strictEqual(_.result(undefined, 'a'), undefined);