File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -131,4 +131,72 @@ describe('FormField', () => {
131
131
expect ( fsComp . prop ( 'uiSchema' ) ) . toStrictEqual ( uiSchema ) ;
132
132
expect ( fsComp . prop ( 'onChange' ) ) . toBe ( onChange ) ;
133
133
} ) ;
134
+
135
+
136
+ it ( 'renders object as FieldSet, passing all properties (With Errors)' , ( ) => {
137
+ const onChange = jest . fn ( ) ;
138
+ const path = 'name' ;
139
+ const schema = {
140
+ 'type' : 'object' ,
141
+ 'properties' : {
142
+ firstName : {
143
+ type : 'string' ,
144
+ title : 'First Name' ,
145
+ } ,
146
+ surname : {
147
+ type : 'string' ,
148
+ title : 'Surname' ,
149
+ } ,
150
+ } ,
151
+ } ;
152
+
153
+ const data = {
154
+ firstName : 'Bob' ,
155
+ surname : 'Hope' ,
156
+ } ;
157
+
158
+ const uiSchema = {
159
+ firstName : { } ,
160
+ surname : { } ,
161
+ } ;
162
+
163
+ const validation = {
164
+ xhr : [
165
+ {
166
+ 'rule' : 'offline' ,
167
+ 'title' : 'You are Offline !' ,
168
+ 'message' : 'Please try again once you are online.' ,
169
+ 'callback' : jest . fn ( ) ,
170
+ } ,
171
+ ] ,
172
+ } ;
173
+
174
+ // act
175
+ const wrapper = mount (
176
+ < FormField
177
+ uiSchema = { uiSchema }
178
+ path = { path }
179
+ schema = { schema }
180
+ data = { data }
181
+ onChange = { onChange }
182
+ xhrSchema = { { } }
183
+ uiData = { { } }
184
+ prefixId = { 'test' }
185
+ validation = { validation }
186
+ id = { 'test' }
187
+ onXHRSchemaEvent = { jest . fn }
188
+ /> ,
189
+ ) ;
190
+
191
+ // check
192
+ expect ( wrapper ) . toHaveLength ( 1 ) ;
193
+ const fsComp = wrapper . find ( FieldSet ) ;
194
+ expect ( fsComp ) . toHaveLength ( 1 ) ;
195
+ expect ( fsComp . prop ( 'path' ) ) . toStrictEqual ( path ) ;
196
+ expect ( fsComp . prop ( 'schema' ) ) . toStrictEqual ( schema ) ;
197
+ expect ( fsComp . prop ( 'data' ) ) . toStrictEqual ( data ) ;
198
+ expect ( fsComp . prop ( 'uiSchema' ) ) . toStrictEqual ( uiSchema ) ;
199
+ expect ( fsComp . prop ( 'validation' ) ) . toStrictEqual ( validation ) ;
200
+ expect ( fsComp . prop ( 'onChange' ) ) . toBe ( onChange ) ;
201
+ } ) ;
134
202
} ) ;
You can’t perform that action at this time.
0 commit comments