1
1
2
2
import React from 'react' ;
3
3
import { configure , mount } from 'enzyme' ;
4
- import Adapter from 'enzyme-adapter-react-15 ' ;
4
+ import Adapter from '@wojtekmaj/ enzyme-adapter-react-17 ' ;
5
5
import { fromJS , List } from 'immutable' ;
6
6
7
7
import AddForm from 'src/standalone/topbar-insert/forms/components/AddForm' ;
@@ -55,7 +55,7 @@ describe('editor topbar insert forms', () => {
55
55
56
56
describe ( 'operation object' , ( ) => {
57
57
let form = operationForm ( null , [ ] ) ;
58
-
58
+
59
59
const tag = form . getIn ( [ 'tags' , 'defaultItem' ] ) ( null , [ ] ) ;
60
60
61
61
form = form
@@ -64,12 +64,12 @@ describe('editor topbar insert forms', () => {
64
64
. setIn ( [ 'description' , 'value' ] , 'test description' )
65
65
. setIn ( [ 'operationid' , 'value' ] , 'testid' )
66
66
. setIn ( [ 'tags' , 'value' ] , new List ( [ tag . setIn ( [ 'tag' , 'value' ] , 'test tag' ) ] ) ) ;
67
-
67
+
68
68
const object = operationObject ( form ) ;
69
69
70
70
it (
71
71
'should correctly process the operation form into the operation object' ,
72
- ( ) => {
72
+ ( ) => {
73
73
const expected = {
74
74
summary : 'test summary' ,
75
75
description : 'test description' ,
@@ -81,15 +81,15 @@ describe('editor topbar insert forms', () => {
81
81
}
82
82
}
83
83
} ;
84
-
84
+
85
85
expect ( object ) . toEqual ( expected ) ;
86
86
}
87
87
) ;
88
-
88
+
89
89
it ( 'should correctly render the form UI for the form object' , ( ) => {
90
90
const element = < InsertForm { ...props } formData = { form } /> ;
91
91
const wrapper = mount ( element ) ;
92
-
92
+
93
93
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 4 ) ;
94
94
expect ( wrapper . find ( 'select' ) . length ) . toEqual ( 2 ) ;
95
95
} ) ;
@@ -99,7 +99,7 @@ describe('editor topbar insert forms', () => {
99
99
const license = licenseForm ( null , [ ] , null )
100
100
. setIn ( [ 'value' , 'name' , 'value' ] , 'test name' )
101
101
. setIn ( [ 'value' , 'url' , 'value' ] , 'test url' ) ;
102
-
102
+
103
103
const contact = contactForm ( null , [ ] )
104
104
. setIn ( [ 'value' , 'name' , 'value' ] , 'test name' )
105
105
. setIn ( [ 'value' , 'url' , 'value' ] , 'test url' )
@@ -115,9 +115,9 @@ describe('editor topbar insert forms', () => {
115
115
116
116
it (
117
117
'should correctly process the info form into the info object' ,
118
- ( ) => {
118
+ ( ) => {
119
119
const object = infoObject ( form ) ;
120
-
120
+
121
121
const expected = {
122
122
title : 'test title' ,
123
123
version : 'test version' ,
@@ -133,15 +133,15 @@ describe('editor topbar insert forms', () => {
133
133
email : 'testemail@test.com'
134
134
}
135
135
} ;
136
-
136
+
137
137
expect ( object ) . toEqual ( expected ) ;
138
138
}
139
139
) ;
140
140
141
141
it ( 'should correctly render the form UI for the form object' , ( ) => {
142
142
const element = < InsertForm { ...props } formData = { form } /> ;
143
143
const wrapper = mount ( element ) ;
144
-
144
+
145
145
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 4 ) ;
146
146
} ) ;
147
147
} ) ;
@@ -155,7 +155,7 @@ describe('editor topbar insert forms', () => {
155
155
. setIn ( [ 'summary' , 'value' ] , 'test summary' )
156
156
. setIn ( [ 'description' , 'value' ] , 'test description' ) ;
157
157
158
- it ( 'should correctly process the path form into the path object' , ( ) => {
158
+ it ( 'should correctly process the path form into the path object' , ( ) => {
159
159
const object = pathObject ( form ) ;
160
160
const expected = {
161
161
key : '/test' ,
@@ -170,18 +170,18 @@ describe('editor topbar insert forms', () => {
170
170
it ( 'should correctly render the form UI for the form object' , ( ) => {
171
171
const element = < InsertForm { ...props } formData = { form } /> ;
172
172
const wrapper = mount ( element ) ;
173
-
173
+
174
174
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 3 ) ;
175
175
} ) ;
176
176
} ) ;
177
177
178
178
describe ( 'tag declarations object' , ( ) => {
179
179
let form = tagsForm ( null , [ ] ) ;
180
-
180
+
181
181
const externalDocs = externalDocumentationForm ( null , [ ] )
182
182
. setIn ( [ 'url' , 'value' ] , 'test url' )
183
183
. setIn ( [ 'description' , 'value' ] , 'test description' ) ;
184
-
184
+
185
185
const tag = tagForm ( null , [ ] )
186
186
. setIn ( [ 'name' , 'value' ] , 'test tag name' )
187
187
. setIn ( [ 'description' , 'value' ] , 'test description' )
@@ -206,12 +206,12 @@ describe('editor topbar insert forms', () => {
206
206
] ;
207
207
expect ( object ) . toEqual ( expected ) ;
208
208
}
209
- ) ;
209
+ ) ;
210
210
211
211
it ( 'should correctly render the form UI for the form object' , ( ) => {
212
212
const element = < InsertForm { ...props } formData = { form } /> ;
213
213
const wrapper = mount ( element ) ;
214
-
214
+
215
215
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 2 ) ;
216
216
} ) ;
217
217
} ) ;
@@ -231,7 +231,7 @@ describe('editor topbar insert forms', () => {
231
231
232
232
it (
233
233
'should correctly process the servers form into the servers object' ,
234
- ( ) => {
234
+ ( ) => {
235
235
const object = serversObject ( form ) ;
236
236
const expected = [
237
237
{
@@ -248,15 +248,15 @@ describe('editor topbar insert forms', () => {
248
248
}
249
249
}
250
250
] ;
251
-
251
+
252
252
expect ( object ) . toEqual ( expected ) ;
253
253
}
254
254
) ;
255
255
256
256
it ( 'should correctly render the form UI for the form object' , ( ) => {
257
257
const element = < InsertForm { ...props } formData = { form } /> ;
258
258
const wrapper = mount ( element ) ;
259
-
259
+
260
260
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 6 ) ;
261
261
} ) ;
262
262
} ) ;
@@ -265,31 +265,31 @@ describe('editor topbar insert forms', () => {
265
265
const selectOperation = selectOperationForm ( null , [ ] )
266
266
. setIn ( [ 'path' , 'value' ] , '/test' )
267
267
. setIn ( [ 'operation' , 'value' ] , 'GET' ) ;
268
-
268
+
269
269
let form = addOperationTagsForm ( null , [ ] )
270
270
. setIn ( [ 'selectoperation' , 'value' ] , selectOperation )
271
271
. setIn ( [ 'tags' , 'value' , 0 , 'tag' , 'value' ] , 'test tag' ) ;
272
272
273
273
it (
274
274
'should correctly process the add tags to operation into the add tags object' ,
275
- ( ) => {
275
+ ( ) => {
276
276
const object = addOperationTagsObject ( form ) ;
277
-
277
+
278
278
const expected = {
279
279
selectedOperation : [ 'paths' , '/test' , 'GET' ] ,
280
280
tags : [
281
281
'test tag'
282
282
]
283
283
} ;
284
-
284
+
285
285
expect ( object ) . toEqual ( expected ) ;
286
286
}
287
287
) ;
288
288
289
289
it ( 'should correctly render the form UI for the form object' , ( ) => {
290
290
const element = < InsertForm { ...props } formData = { form } /> ;
291
291
const wrapper = mount ( element ) ;
292
-
292
+
293
293
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 1 ) ;
294
294
expect ( wrapper . find ( 'select' ) . length ) . toEqual ( 2 ) ;
295
295
} ) ;
@@ -301,31 +301,31 @@ describe('editor topbar insert forms', () => {
301
301
. setIn ( [ 'operation' , 'value' ] , 'GET' )
302
302
. setIn ( [ 'response' , 'value' ] , '200' )
303
303
. setIn ( [ 'mediatype' , 'value' ] , 'application/json' ) ;
304
-
304
+
305
305
let form = exampleForm ( null , [ ] )
306
306
. setIn ( [ 'selectresponse' , 'value' ] , selectResponse )
307
307
. setIn ( [ 'exampleName' , 'value' ] , 'sample example name' )
308
308
. setIn ( [ 'exampleValue' , 'value' ] , 'sample example value' ) ;
309
309
310
310
it (
311
311
'should correctly process the add example form into the form values object' ,
312
- ( ) => {
312
+ ( ) => {
313
313
const object = exampleObject ( form ) ;
314
-
314
+
315
315
const expected = {
316
316
responsePath : [ 'paths' , '/test' , 'GET' , 'responses' , '200' , 'content' , 'application/json' , 'examples' ] ,
317
317
exampleValue : 'sample example value' ,
318
318
exampleName : 'sample example name'
319
319
} ;
320
-
320
+
321
321
expect ( object ) . toEqual ( expected ) ;
322
322
}
323
323
) ;
324
324
325
325
it ( 'should correctly render the form UI for the form object' , ( ) => {
326
326
const element = < InsertForm { ...props } formData = { form } /> ;
327
327
const wrapper = mount ( element ) ;
328
-
328
+
329
329
expect ( wrapper . find ( 'input' ) . length ) . toEqual ( 1 ) ;
330
330
expect ( wrapper . find ( 'select' ) . length ) . toEqual ( 4 ) ;
331
331
} ) ;
0 commit comments