Fix obscure config merge bug.

This commit is contained in:
Dermot Duffy
2024-03-03 18:22:51 -08:00
parent 8f3c6af38f
commit 89ddea69db
4 changed files with 96 additions and 12 deletions
+47
View File
@@ -18,6 +18,7 @@ import {
isTruthy,
isValidDate,
prettifyTitle,
recursivelyMergeObjectsNotArrays,
runWhenIdleIfSupported,
setOrRemoveAttribute,
setify,
@@ -291,3 +292,49 @@ describe('getChildrenFromElement', () => {
expect(getChildrenFromElement(slot)).toEqual(children);
});
});
describe('recursivelyMergeObjectsNotArrays', () => {
it('should recursively merge objects but replace arrays', () => {
expect(
recursivelyMergeObjectsNotArrays(
{
a: {
b: {
c: 3,
d: {
e: 4,
},
array: [1, 2, 3],
},
other: {
field: 7,
},
},
},
{
a: {
b: {
array: [4],
d: {
e: 5,
},
},
},
},
),
).toEqual({
a: {
b: {
c: 3,
array: [4],
d: {
e: 5,
},
},
other: {
field: 7,
},
},
});
});
});