File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export function transformOutputValue(value, content) {
4343 const newVal = { }
4444 Object . keys ( value ) . forEach ( id => {
4545 const item = content . find ( item => item . id === id )
46+ if ( ! item ) return
4647 if ( item . type !== 'group' ) {
4748 if ( item . outputFormat ) {
4849 const v = item . outputFormat ( value [ id ] )
Original file line number Diff line number Diff line change @@ -129,6 +129,39 @@ describe('transformOutputValue', () => {
129129 ]
130130 expect ( transformOutputValue ( v , content ) ) . toEqual ( v )
131131 } )
132+
133+ test ( 'form oldV和content的key没有对应上的情况' , ( ) => {
134+ const oldV = {
135+ a : 1 ,
136+ b : {
137+ c : 2 ,
138+ d : 3 ,
139+ } ,
140+ }
141+ const newV = {
142+ b : {
143+ c : 1 ,
144+ e : 4 ,
145+ } ,
146+ }
147+ const content = [
148+ {
149+ id : 'b' ,
150+ type : 'group' ,
151+ items : [
152+ {
153+ id : 'c' ,
154+ outputFormat : c => c - 1 ,
155+ } ,
156+ {
157+ id : 'd' ,
158+ outputFormat : d => ( { e : d + 1 } ) ,
159+ } ,
160+ ] ,
161+ } ,
162+ ]
163+ expect ( transformOutputValue ( oldV , content ) ) . toEqual ( newV )
164+ } )
132165} )
133166
134167describe ( 'transformInputValue' , ( ) => {
You can’t perform that action at this time.
0 commit comments