From c066e655dce3a4263feecf9979c5ca1a7ec7355e Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 6 Apr 2015 12:04:07 -0500 Subject: [PATCH] Add empty path and array path coercing `_.set` test. --- test/test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test.js b/test/test.js index d2a766830..d85692b28 100644 --- a/test/test.js +++ b/test/test.js @@ -13256,6 +13256,22 @@ }); }); + test('should not coerce array paths to strings', 1, function() { + var object = { 'a,b,c': 3, 'a': { 'b': { 'c': 3 } } }; + _.set(object, ['a', 'b', 'c'], 4); + deepEqual(object, { 'a,b,c': 3, 'a': { 'b': { 'c': 4 } } }); + }); + + test('should handle empty paths', 4, function() { + _.each([['', ''], [[], ['']]], function(paths, index) { + var object = {}; + _.set(object, paths[0], 1); + deepEqual(object, index ? {} : { '': 1 }); + _.set(object, paths[1], 2); + deepEqual(object, { '': 2 }); + }); + }); + test('should create parts of `path` that are missing', 6, function() { var object = {};