@@ -31,7 +31,14 @@ describe('FormMutations', () => {
31
31
const onError = jest . fn ( ) ;
32
32
const params = {
33
33
uiSchema : { } ,
34
- xhrSchema : { } ,
34
+ xhrSchema : {
35
+ "ui:errors" : {
36
+ "offline" : {
37
+ "title" : "You are Offline !" ,
38
+ "message" : "Please try again once you are online."
39
+ }
40
+ }
41
+ } ,
35
42
formSchema : { } ,
36
43
formData : { } ,
37
44
uiData : { } ,
@@ -63,7 +70,7 @@ describe('FormMutations', () => {
63
70
} ) ;
64
71
const contextMutations = JSON . parse ( JSON . stringify ( updateMutation . context ) ) ;
65
72
delete contextMutations . effects ;
66
- const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { } , "xhrSchema" : { } }
73
+ const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { } , "xhrSchema" : params . xhrSchema }
67
74
expect ( contextMutations ) . toStrictEqual ( expected ) ;
68
75
expect ( onChange ) . toHaveBeenCalledTimes ( 2 ) ;
69
76
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
@@ -81,7 +88,7 @@ describe('FormMutations', () => {
81
88
} ) ;
82
89
const contextMutations = JSON . parse ( JSON . stringify ( updateFormOnXHRComplete . context ) ) ;
83
90
delete contextMutations . effects ;
84
- const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
91
+ const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : params . xhrSchema } ;
85
92
expect ( contextMutations ) . toStrictEqual ( expected ) ;
86
93
expect ( onChange ) . toHaveBeenCalledTimes ( 3 ) ;
87
94
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
@@ -91,7 +98,7 @@ describe('FormMutations', () => {
91
98
const updateFormOnXHRComplete = stateMachineService . send ( 'updateFormOnXHRComplete' , { } ) ;
92
99
const contextMutations = JSON . parse ( JSON . stringify ( updateFormOnXHRComplete . context ) ) ;
93
100
delete contextMutations . effects ;
94
- const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
101
+ const expected = { "activeStep" : 0 , "formData" : { "test" : "test-2" } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : params . xhrSchema } ;
95
102
expect ( contextMutations ) . toStrictEqual ( expected ) ;
96
103
expect ( onChange ) . toHaveBeenCalledTimes ( 4 ) ;
97
104
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
@@ -106,7 +113,7 @@ describe('FormMutations', () => {
106
113
} ) ;
107
114
const contextMutations = JSON . parse ( JSON . stringify ( updateMutation . context ) ) ;
108
115
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" : { } } ;
116
+ const expected = { "activeStep" : 0 , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : params . xhrSchema } ;
110
117
expect ( contextMutations ) . toStrictEqual ( expected ) ;
111
118
expect ( onChange ) . toHaveBeenCalledTimes ( 5 ) ;
112
119
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
@@ -119,7 +126,7 @@ describe('FormMutations', () => {
119
126
} ) ;
120
127
const contextMutations = JSON . parse ( JSON . stringify ( noErrors . context ) ) ;
121
128
delete contextMutations . effects ;
122
- const expected = { "activeStep" : 0 , "hasError" : false , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : { } } ;
129
+ const expected = { "activeStep" : 0 , "hasError" : false , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasXHRError" : false , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validations" : { } , "xhrProgress" : { "undefined" : false } , "xhrSchema" : params . xhrSchema } ;
123
130
expect ( contextMutations ) . toStrictEqual ( expected ) ;
124
131
expect ( onChange ) . toHaveBeenCalledTimes ( 5 ) ;
125
132
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "dirty" } ) ;
@@ -140,7 +147,7 @@ describe('FormMutations', () => {
140
147
} ) ;
141
148
const contextMutations = JSON . parse ( JSON . stringify ( updateErrorXHRProgress . context ) ) ;
142
149
delete contextMutations . effects ;
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" : { } } ;
150
+ 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" : params . xhrSchema } ;
144
151
expect ( contextMutations ) . toStrictEqual ( expected ) ;
145
152
expect ( onChange ) . toHaveBeenCalledTimes ( 6 ) ;
146
153
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "invalid" } ) ;
@@ -161,7 +168,7 @@ describe('FormMutations', () => {
161
168
} ) ;
162
169
const contextMutations = JSON . parse ( JSON . stringify ( updateErrorXHRProgress . context ) ) ;
163
170
delete contextMutations . effects ;
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" : { } } ;
171
+ const expected = { "activeStep" : 0 , "formData" : { } , "formSchema" : { } , "formSchemaXHR" : { "new" : "info" } , "hasError" : false , "hasXHRError" : true , "lastField" : "test" , "parsedFormSchema" : { } , "uiData" : { } , "uiSchema" : { } , "validation" : { "xhr" : [ { "message" : "Please try again once you are online." , "rule" : "offline" , "title" : "You are Offline !" } ] } , "validations" : { } , "xhrProgress" : { "undefined" : true } , "xhrSchema" : { "ui:errors" : { "offline" : { "message" : "Please try again once you are online." , "title" : "You are Offline !" } } } } ;
165
172
expect ( contextMutations ) . toStrictEqual ( expected ) ;
166
173
expect ( onChange ) . toHaveBeenCalledTimes ( 7 ) ;
167
174
expect ( stateMachineService . state . value ) . toStrictEqual ( { "formUI" : "invalid" } ) ;
0 commit comments