@@ -97,15 +97,31 @@ describe('FormMutations', () => {
97
97
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
98
98
} ) ;
99
99
100
+ it ( 'updateArrayData' , ( ) => {
101
+ const updateArrayFN = jest . fn ( ) ;
102
+ const updateMutation = stateMachineService . send ( 'moveItemUp' , {
103
+ field : 'test' ,
104
+ givenValue : 'test-2' ,
105
+ updateArrayFN,
106
+ } ) ;
107
+ const contextMutations = JSON . parse ( JSON . stringify ( updateMutation . context ) ) ;
108
+ delete contextMutations . effects ;
109
+ const expected = { "activeStep" : 0 , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
110
+ expect ( contextMutations ) . toStrictEqual ( expected ) ;
111
+ expect ( onChange ) . toHaveBeenCalledTimes ( 5 ) ;
112
+ expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
113
+ expect ( updateArrayFN ) . toHaveBeenCalledTimes ( 1 ) ;
114
+ } ) ;
115
+
100
116
it ( 'updateErrorData' , ( ) => {
101
117
const noErrors = stateMachineService . send ( 'noErrors' , {
102
118
hasError : false ,
103
119
} ) ;
104
120
const contextMutations = JSON . parse ( JSON . stringify ( noErrors . context ) ) ;
105
121
delete contextMutations . effects ;
106
- const expected = { "activeStep" : 0 , "hasError" : false , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
122
+ const expected = { "activeStep" : 0 , "hasError" : false , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
107
123
expect ( contextMutations ) . toStrictEqual ( expected ) ;
108
- expect ( onChange ) . toHaveBeenCalledTimes ( 4 ) ;
124
+ expect ( onChange ) . toHaveBeenCalledTimes ( 5 ) ;
109
125
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
110
126
} ) ;
111
127
@@ -124,9 +140,9 @@ describe('FormMutations', () => {
124
140
} ) ;
125
141
const contextMutations = JSON . parse ( JSON . stringify ( updateErrorXHRProgress . context ) ) ;
126
142
delete contextMutations . effects ;
127
- const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : true , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { "xhr" : [ ] } , "validations" : { } , "xhrProgress" : { "undefined" : true } , "xhrSchema" : { } } ;
143
+ const expected = { "activeStep" : 0 , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : true , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { "xhr" : [ ] } , "validations" : { } , "xhrProgress" : { "undefined" : true } , "xhrSchema" : { } } ;
128
144
expect ( contextMutations ) . toStrictEqual ( expected ) ;
129
- expect ( onChange ) . toHaveBeenCalledTimes ( 5 ) ;
145
+ expect ( onChange ) . toHaveBeenCalledTimes ( 6 ) ;
130
146
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "invalid" } ) ;
131
147
} ) ;
132
148
@@ -145,9 +161,9 @@ describe('FormMutations', () => {
145
161
} ) ;
146
162
const contextMutations = JSON . parse ( JSON . stringify ( updateErrorXHRProgress . context ) ) ;
147
163
delete contextMutations . effects ;
148
- const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : true , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { "xhr" : [ ] } , "validations" : { } , "xhrProgress" : { "undefined" : true } , "xhrSchema" : { } } ;
164
+ const expected = { "activeStep" : 0 , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : true , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { "xhr" : [ ] } , "validations" : { } , "xhrProgress" : { "undefined" : true } , "xhrSchema" : { } } ;
149
165
expect ( contextMutations ) . toStrictEqual ( expected ) ;
150
- expect ( onChange ) . toHaveBeenCalledTimes ( 6 ) ;
166
+ expect ( onChange ) . toHaveBeenCalledTimes ( 7 ) ;
151
167
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "invalid" } ) ;
152
168
} ) ;
153
169
} ) ;
0 commit comments