@@ -101,66 +101,6 @@ describe('JSONArray', () => {
101
101
expect ( container . querySelectorAll ( JSON_ARRAY_DOT ) ) . toHaveLength ( 2 )
102
102
} )
103
103
104
- it ( 'should render simple not downloaded JSON' , async ( ) => {
105
- const fetchVisualisationResults = jest . fn ( ) . mockReturnValue (
106
- Promise . resolve ( { data : mockedDownloadedSimpleArray } )
107
- )
108
- const { container } = render ( < RejsonArray
109
- { ...instance ( mockedProps ) }
110
- keyName = "keyName"
111
- value = { mockedDownloadedSimpleArray }
112
- shouldRejsonDataBeDownloaded
113
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
114
- handleFetchVisualisationResults = { fetchVisualisationResults }
115
- /> )
116
-
117
- await act ( async ( ) => {
118
- await fireEvent . click ( screen . getByTestId ( EXPAND_ARRAY ) )
119
- } )
120
-
121
- expect ( container . querySelectorAll ( JSON_ARRAY_DOT ) ) . toHaveLength ( 3 )
122
- } )
123
-
124
- it ( 'should render not downloaded JSON with arrays' , async ( ) => {
125
- const fetchVisualisationResults = jest . fn ( ) . mockReturnValue (
126
- Promise . resolve ( { data : mockedDownloadedArrayWithArrays } )
127
- )
128
- const { container } = render ( < RejsonArray
129
- { ...instance ( mockedProps ) }
130
- keyName = "keyName"
131
- value = { mockedDownloadedSimpleArray }
132
- shouldRejsonDataBeDownloaded
133
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
134
- handleFetchVisualisationResults = { fetchVisualisationResults }
135
- /> )
136
-
137
- await act ( async ( ) => {
138
- await fireEvent . click ( screen . getByTestId ( EXPAND_ARRAY ) )
139
- } )
140
-
141
- expect ( container . querySelectorAll ( JSON_ARRAY_DOT ) ) . toHaveLength ( 4 )
142
- } )
143
-
144
- it ( 'should render not downloaded JSON with objects' , async ( ) => {
145
- const fetchVisualisationResults = jest . fn ( ) . mockReturnValue (
146
- Promise . resolve ( { data : mockedDownloadedArrayWithObjects } )
147
- )
148
- const { container } = render ( < RejsonArray
149
- { ...instance ( mockedProps ) }
150
- keyName = "keyName"
151
- value = { mockedDownloadedSimpleArray }
152
- shouldRejsonDataBeDownloaded
153
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
154
- handleFetchVisualisationResults = { fetchVisualisationResults }
155
- /> )
156
-
157
- await act ( async ( ) => {
158
- await fireEvent . click ( screen . getByTestId ( EXPAND_ARRAY ) )
159
- } )
160
-
161
- expect ( container . querySelectorAll ( JSON_ARRAY_DOT ) ) . toHaveLength ( 6 )
162
- } )
163
-
164
104
it ( 'should render inline editor to add' , async ( ) => {
165
105
render ( < RejsonArray
166
106
{ ...instance ( mockedProps ) }
@@ -246,92 +186,4 @@ describe('JSONArray', () => {
246
186
expect ( handleSubmitJsonUpdateValue ) . toBeCalled ( )
247
187
expect ( handleAppendRejsonArrayItemAction ) . toBeCalled ( )
248
188
} )
249
-
250
- it ( 'should render inline editor to edit value' , async ( ) => {
251
- render ( < RejsonArray
252
- { ...instance ( mockedProps ) }
253
- keyName = "keyName"
254
- value = { mockedDownloadedSimpleArray }
255
- shouldRejsonDataBeDownloaded = { false }
256
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
257
- /> )
258
-
259
- await act ( async ( ) => {
260
- await fireEvent . click ( screen . getByTestId ( BTN_EDIT_FIELD ) )
261
- } )
262
-
263
- expect ( screen . getByTestId ( JSON_ARRAY ) ) . toBeInTheDocument ( )
264
- } )
265
-
266
- it ( 'should change value when editing' , async ( ) => {
267
- render ( < RejsonArray
268
- { ...instance ( mockedProps ) }
269
- keyName = "keyName"
270
- value = { mockedDownloadedSimpleArray }
271
- shouldRejsonDataBeDownloaded = { false }
272
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
273
- /> )
274
-
275
- await act ( async ( ) => {
276
- await fireEvent . click ( screen . getByTestId ( BTN_EDIT_FIELD ) )
277
- } )
278
-
279
- fireEvent . change ( screen . getByTestId ( JSON_ARRAY ) , {
280
- target : { value : '[]' }
281
- } )
282
-
283
- expect ( screen . getByTestId ( JSON_ARRAY ) ) . toHaveValue ( '[]' )
284
- } )
285
-
286
- it ( 'should not be apply wrong value for edit' , async ( ) => {
287
- const onJSONPropertyEdited = jest . fn ( )
288
- render ( < RejsonArray
289
- { ...instance ( mockedProps ) }
290
- keyName = "keyName"
291
- value = { mockedDownloadedSimpleArray }
292
- shouldRejsonDataBeDownloaded = { false }
293
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
294
- handleSubmitJsonUpdateValue = { jest . fn ( ) }
295
- /> )
296
-
297
- await act ( async ( ) => {
298
- await fireEvent . click ( screen . getByTestId ( BTN_EDIT_FIELD ) )
299
- } )
300
-
301
- fireEvent . change ( screen . getByTestId ( JSON_ARRAY ) , {
302
- target : { value : '{' }
303
- } )
304
-
305
- await act ( async ( ) => {
306
- await fireEvent . click ( screen . getByTestId ( 'apply-edit-btn' ) )
307
- } )
308
-
309
- expect ( onJSONPropertyEdited ) . not . toBeCalled ( )
310
- } )
311
-
312
- it ( 'should apply proper value for edit' , async ( ) => {
313
- const onJSONPropertyEdited = jest . fn ( )
314
- render ( < RejsonArray
315
- { ...instance ( mockedProps ) }
316
- keyName = "keyName"
317
- value = { mockedDownloadedSimpleArray }
318
- shouldRejsonDataBeDownloaded = { false }
319
- onJsonKeyExpandAndCollapse = { jest . fn ( ) }
320
- handleSubmitJsonUpdateValue = { jest . fn ( ) }
321
- /> )
322
-
323
- await act ( async ( ) => {
324
- await fireEvent . click ( screen . getByTestId ( BTN_EDIT_FIELD ) )
325
- } )
326
-
327
- fireEvent . change ( screen . getByTestId ( JSON_ARRAY ) , {
328
- target : { value : '{}' }
329
- } )
330
-
331
- await act ( async ( ) => {
332
- await fireEvent . click ( screen . getByTestId ( 'apply-edit-btn' ) )
333
- } )
334
-
335
- expect ( onJSONPropertyEdited ) . toBeCalled ( )
336
- } )
337
189
} )
0 commit comments