mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add _.set test for non-deep paths.
This commit is contained in:
15
test/test.js
15
test/test.js
@@ -6025,10 +6025,10 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
test('should get property values', 2, function() {
|
test('should get property values', 2, function() {
|
||||||
var object = { 'a': 'b' };
|
var object = { 'a': 1 };
|
||||||
|
|
||||||
_.each(['a', ['a']], function(path) {
|
_.each(['a', ['a']], function(path) {
|
||||||
strictEqual(_.get(object, path), 'b');
|
strictEqual(_.get(object, path), 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -13234,6 +13234,17 @@
|
|||||||
QUnit.module('lodash.set');
|
QUnit.module('lodash.set');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
test('should set property values', 4, function() {
|
||||||
|
var object = { 'a': 1 };
|
||||||
|
|
||||||
|
_.each(['a', ['a']], function(path) {
|
||||||
|
var actual = _.set(object, path, 2);
|
||||||
|
strictEqual(actual, object);
|
||||||
|
strictEqual(object.a, 2);
|
||||||
|
object.a = 1;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('should set deep property values', 4, function() {
|
test('should set deep property values', 4, function() {
|
||||||
var object = { 'a': { 'b': { 'c': 3 } } };
|
var object = { 'a': { 'b': { 'c': 3 } } };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user