File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -107,4 +107,22 @@ describe('mergeWith', () => {
107107
108108 expect ( result ) . toEqual ( { a : 3 , b : 2 } ) ;
109109 } ) ;
110+
111+ it ( 'should replace non-plain-object target value with plain object from source when merge returns undefined' , ( ) => {
112+ const target = { a : 'string' , b : 123 , c : true } ;
113+ const source = { a : { x : 1 } , b : { y : 2 } , c : { z : 3 } } ;
114+
115+ const result = mergeWith ( target , source , ( ) => undefined ) ;
116+
117+ expect ( result ) . toEqual ( { a : { x : 1 } , b : { y : 2 } , c : { z : 3 } } ) ;
118+ } ) ;
119+
120+ it ( 'should handle nested case where non-plain-object is replaced with plain object when merge returns undefined' , ( ) => {
121+ const target = { a : { b : null , c : undefined , d : 'text' } } ;
122+ const source = { a : { b : { x : 1 } , c : { y : 2 } , d : { z : 3 } } } ;
123+
124+ const result = mergeWith ( target , source , ( ) => undefined ) ;
125+
126+ expect ( result ) . toEqual ( { a : { b : { x : 1 } , c : { y : 2 } , d : { z : 3 } } } ) ;
127+ } ) ;
110128} ) ;
You can’t perform that action at this time.
0 commit comments