Skip to content

Commit

Permalink
added commented out test for Including parent items in arrays wankdan…
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Switzer committed Oct 11, 2019
1 parent 7d8252d commit d57b328
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/object-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ function update_arr(dest, key, data, keys, context)
if (key.add) {
if (data !== null && typeof data !== 'undefined') {
dest = dest || []
dest.push(data)
//dest.push(data)
dest = dest.concat(data)
}
return dest
}

// Make sure that there is an array item for each item in the data array
// If the data is in an array format then make sure that there is a dest index for each data index
if (Array.isArray(data)) {
dest = dest || []
// Loop through each index in the data array and update the destination object with the data
Expand Down
32 changes: 32 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2202,3 +2202,35 @@ test('2 array mapping wraps destination in an unwanted array #49', function (t)
t.end();
});

// test('Including parent items in arrays #50', function (t) {
// const src = {
// "a": "AA",
// "b": "BB",
// "array": [
// { "x": "one" },
// { "x": "two" }
// ]
// };
// const map = {
// "array[].x": "results[].ex",
// "a": "results[].aye",
// "b": "results[].bee"
// }
// var expect = {
// "results": [
// {
// "aye": "AA",
// "bee": "BB",
// "ex": "one"
// },
// {
// "aye": "AA",
// "bee": "BB",
// "ex": "two"
// }
// ]
// };
// var result = om(src, map);
// t.deepEqual(result, expect);
// t.end();
// });

0 comments on commit d57b328

Please sign in to comment.