Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
BUGFIX: Fix splitting of keys in operation when handling deep object …
Browse files Browse the repository at this point in the history
…structures #12
  • Loading branch information
grebaldi committed Oct 7, 2016
1 parent 6a665fe commit b3561f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/migrations/molecules/merge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const merge = (path, value, subject) => Object.keys(value).reduce(
return merge([...path, key], value[key], subject);
}

return $set([...resolveObjectPath(path), ...key], value[key], subject);
return $set([...resolveObjectPath(path), key], value[key], subject);
},
subject
);
Expand Down
30 changes: 30 additions & 0 deletions src/migrations/molecules/merge/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,36 @@ describe('Migrations > Atoms > $merge', () => {
const subject = undefined;
expect($merge('some.path', {some: 'value'}, subject)).to.be.an('undefined');
});

it('should not split up keys in deep object structures (bugfix #12)', () => {
const subject = {
test: {
a: {
b: {
cdef: 'c'
}
}
}
};
const result = $merge('test', {
a: {
b: {
cdef: 'foo'
}
}
}, subject);

expect(result.test.a.b.c).to.be.an('undefined');
expect(result).to.deep.equal({
test: {
a: {
b: {
cdef: 'foo'
}
}
}
});
});
});

describe('Immutable', () => {
Expand Down

0 comments on commit b3561f2

Please sign in to comment.