1
- import React from " react"
2
- import { shallow , render , mount } from " enzyme"
3
- import { expect } from " chai"
1
+ import React from ' react' ;
2
+ import { shallow , render , mount } from ' enzyme' ;
3
+ import { expect } from ' chai' ;
4
4
5
- import JsonObject from " ./../../../../../src/js/components/DataTypes/Object"
5
+ import JsonObject from ' ./../../../../../src/js/components/DataTypes/Object' ;
6
6
7
- describe ( " <JsonObject />" , function ( ) {
8
- const rjvId = 1
7
+ describe ( ' <JsonObject />' , function ( ) {
8
+ const rjvId = 1 ;
9
9
10
- it ( " Object component should have a data type label" , function ( ) {
10
+ it ( ' Object component should have a data type label' , function ( ) {
11
11
let src = {
12
12
test : true
13
- }
13
+ } ;
14
14
const wrapper = shallow (
15
15
< JsonObject
16
16
src = { src }
17
- namespace = { [ " root" ] }
17
+ namespace = { [ ' root' ] }
18
18
rjvId = { rjvId }
19
19
theme = "rjv-default"
20
20
indentWidth = { 1 }
21
21
depth = { 1 }
22
22
displayDataTypes = { true }
23
23
type = "object"
24
24
/>
25
- )
26
- expect ( wrapper . find ( " .object-key-val" ) ) . to . have . length ( 1 )
27
- } )
25
+ ) ;
26
+ expect ( wrapper . find ( ' .object-key-val' ) ) . to . have . length ( 1 ) ;
27
+ } ) ;
28
28
29
- it ( " Object mount, multiple data type labels" , function ( ) {
29
+ it ( ' Object mount, multiple data type labels' , function ( ) {
30
30
let src = {
31
31
bool : true , //should have label
32
32
int : 5 , //should have label
33
- str : " test" , //should have label
33
+ str : ' test' , //should have label
34
34
nan : NaN ,
35
35
null : null ,
36
36
undefined : undefined ,
37
- func : function ( ) { } , //should have label
37
+ func : function ( ) { } , //should have label
38
38
float : 1.325 , //should have label
39
39
arr : [
40
40
1 , //should have label
@@ -45,11 +45,11 @@ describe("<JsonObject />", function() {
45
45
} ,
46
46
empty_arr : [ ] ,
47
47
empty_obj : { }
48
- }
48
+ } ;
49
49
const wrapper = render (
50
50
< JsonObject
51
51
src = { src }
52
- namespace = { [ " root" ] }
52
+ namespace = { [ ' root' ] }
53
53
rjvId = { rjvId }
54
54
theme = "rjv-default"
55
55
indentWidth = { 1 }
@@ -58,19 +58,19 @@ describe("<JsonObject />", function() {
58
58
displayDataTypes = { true }
59
59
type = "object"
60
60
/>
61
- )
62
- expect ( wrapper . find ( " .data-type-label" ) ) . to . have . length ( 8 )
63
- } )
61
+ ) ;
62
+ expect ( wrapper . find ( ' .data-type-label' ) ) . to . have . length ( 8 ) ;
63
+ } ) ;
64
64
65
- it ( " Object mount, no data type labels when collapsed" , function ( ) {
65
+ it ( ' Object mount, no data type labels when collapsed' , function ( ) {
66
66
let src = {
67
67
bool : true , //should have label
68
68
int : 5 , //should have label
69
- str : " test" , //should have label
69
+ str : ' test' , //should have label
70
70
nan : NaN ,
71
71
null : null ,
72
72
undefined : undefined ,
73
- func : function ( ) { } , //should have label
73
+ func : function ( ) { } , //should have label
74
74
float : 1.325 , //should have label
75
75
arr : [
76
76
1 , //should have label
@@ -79,11 +79,11 @@ describe("<JsonObject />", function() {
79
79
obj : {
80
80
test : true //should have label
81
81
}
82
- }
82
+ } ;
83
83
const wrapper = render (
84
84
< JsonObject
85
85
src = { src }
86
- namespace = { [ " root" ] }
86
+ namespace = { [ ' root' ] }
87
87
rjvId = { rjvId }
88
88
theme = "rjv-default"
89
89
indentWidth = { 1 }
@@ -92,18 +92,18 @@ describe("<JsonObject />", function() {
92
92
collapsed = { true }
93
93
type = "object"
94
94
/>
95
- )
96
- expect ( wrapper . find ( " .data-type-label" ) ) . to . have . length ( 0 )
97
- } )
95
+ ) ;
96
+ expect ( wrapper . find ( ' .data-type-label' ) ) . to . have . length ( 0 ) ;
97
+ } ) ;
98
98
99
- it ( " Array mount expanded" , function ( ) {
99
+ it ( ' Array mount expanded' , function ( ) {
100
100
let src = {
101
- arr1 : [ ( " arr2" : [ " test" ] ) ]
102
- }
101
+ arr1 : [ ( ' arr2' : [ ' test' ] ) ]
102
+ } ;
103
103
const wrapper = render (
104
104
< JsonObject
105
105
src = { src }
106
- namespace = { [ " arr_test" ] }
106
+ namespace = { [ ' arr_test' ] }
107
107
name = "test"
108
108
rjvId = { rjvId }
109
109
theme = "rjv-default"
@@ -113,19 +113,19 @@ describe("<JsonObject />", function() {
113
113
displayDataTypes = { true }
114
114
type = "array"
115
115
/>
116
- )
117
- expect ( wrapper . find ( " .expanded-icon" ) ) . to . have . length ( 2 )
118
- expect ( wrapper . find ( " .collapsed-icon" ) ) . to . have . length ( 0 )
119
- } )
116
+ ) ;
117
+ expect ( wrapper . find ( ' .expanded-icon' ) ) . to . have . length ( 2 ) ;
118
+ expect ( wrapper . find ( ' .collapsed-icon' ) ) . to . have . length ( 0 ) ;
119
+ } ) ;
120
120
121
- it ( " Array mount collapsed" , function ( ) {
121
+ it ( ' Array mount collapsed' , function ( ) {
122
122
let src = {
123
- arr1 : [ ( " arr2" : [ " test" ] ) ]
124
- }
123
+ arr1 : [ ( ' arr2' : [ ' test' ] ) ]
124
+ } ;
125
125
const wrapper = render (
126
126
< JsonObject
127
127
src = { src }
128
- namespace = { [ " arr_test" ] }
128
+ namespace = { [ ' arr_test' ] }
129
129
name = "test"
130
130
rjvId = { rjvId }
131
131
theme = "rjv-default"
@@ -134,19 +134,19 @@ describe("<JsonObject />", function() {
134
134
depth = { 1 }
135
135
type = "array"
136
136
/>
137
- )
138
- expect ( wrapper . find ( " .expanded-icon" ) ) . to . have . length ( 0 )
139
- expect ( wrapper . find ( " .collapsed-icon" ) ) . to . have . length ( 1 )
140
- } )
137
+ ) ;
138
+ expect ( wrapper . find ( ' .expanded-icon' ) ) . to . have . length ( 0 ) ;
139
+ expect ( wrapper . find ( ' .collapsed-icon' ) ) . to . have . length ( 1 ) ;
140
+ } ) ;
141
141
142
- it ( " Array mount collapsed circle" , function ( ) {
142
+ it ( ' Array mount collapsed circle' , function ( ) {
143
143
let src = {
144
- arr1 : [ ( " arr2" : [ " test" ] ) ]
145
- }
144
+ arr1 : [ ( ' arr2' : [ ' test' ] ) ]
145
+ } ;
146
146
const wrapper = render (
147
147
< JsonObject
148
148
src = { src }
149
- namespace = { [ " arr_test" ] }
149
+ namespace = { [ ' arr_test' ] }
150
150
name = "test"
151
151
rjvId = { rjvId }
152
152
theme = "rjv-default"
@@ -155,19 +155,19 @@ describe("<JsonObject />", function() {
155
155
depth = { 1 }
156
156
type = "array"
157
157
/>
158
- )
159
- expect ( wrapper . find ( " .expanded-icon" ) ) . to . have . length ( 0 )
160
- expect ( wrapper . find ( " .collapsed-icon" ) ) . to . have . length ( 1 )
161
- } )
158
+ ) ;
159
+ expect ( wrapper . find ( ' .expanded-icon' ) ) . to . have . length ( 0 ) ;
160
+ expect ( wrapper . find ( ' .collapsed-icon' ) ) . to . have . length ( 1 ) ;
161
+ } ) ;
162
162
163
- it ( " Array mount collapsed square" , function ( ) {
163
+ it ( ' Array mount collapsed square' , function ( ) {
164
164
let src = {
165
- arr1 : [ ( " arr2" : [ " test" ] ) ]
166
- }
165
+ arr1 : [ ( ' arr2' : [ ' test' ] ) ]
166
+ } ;
167
167
const wrapper = render (
168
168
< JsonObject
169
169
src = { src }
170
- namespace = { [ " arr_test" ] }
170
+ namespace = { [ ' arr_test' ] }
171
171
name = "test"
172
172
rjvId = { rjvId }
173
173
theme = "rjv-default"
@@ -177,19 +177,19 @@ describe("<JsonObject />", function() {
177
177
iconStyle = "square"
178
178
type = "array"
179
179
/>
180
- )
181
- expect ( wrapper . find ( " .expanded-icon" ) ) . to . have . length ( 0 )
182
- expect ( wrapper . find ( " .collapsed-icon" ) ) . to . have . length ( 1 )
183
- } )
180
+ ) ;
181
+ expect ( wrapper . find ( ' .expanded-icon' ) ) . to . have . length ( 0 ) ;
182
+ expect ( wrapper . find ( ' .collapsed-icon' ) ) . to . have . length ( 1 ) ;
183
+ } ) ;
184
184
185
- it ( " Array mount collapsed triangle" , function ( ) {
185
+ it ( ' Array mount collapsed triangle' , function ( ) {
186
186
let src = {
187
- arr1 : [ ( " arr2" : [ " test" ] ) ]
188
- }
187
+ arr1 : [ ( ' arr2' : [ ' test' ] ) ]
188
+ } ;
189
189
const wrapper = render (
190
190
< JsonObject
191
191
src = { src }
192
- namespace = { [ " arr_test" ] }
192
+ namespace = { [ ' arr_test' ] }
193
193
name = "test"
194
194
rjvId = { rjvId }
195
195
theme = "rjv-default"
@@ -199,172 +199,178 @@ describe("<JsonObject />", function() {
199
199
iconStyle = "triangle"
200
200
type = "array"
201
201
/>
202
- )
203
- expect ( wrapper . find ( " .expanded-icon" ) ) . to . have . length ( 0 )
204
- expect ( wrapper . find ( " .collapsed-icon" ) ) . to . have . length ( 1 )
205
- } )
202
+ ) ;
203
+ expect ( wrapper . find ( ' .expanded-icon' ) ) . to . have . length ( 0 ) ;
204
+ expect ( wrapper . find ( ' .collapsed-icon' ) ) . to . have . length ( 1 ) ;
205
+ } ) ;
206
206
207
- it ( " non-empty object should be expanded" , function ( ) {
208
- let src = { test : true }
207
+ it ( ' non-empty object should be expanded' , function ( ) {
208
+ let src = { test : true } ;
209
209
210
210
const wrapper = shallow (
211
211
< JsonObject
212
212
src = { src }
213
213
theme = "rjv-default"
214
- namespace = { [ " root" ] }
214
+ namespace = { [ ' root' ] }
215
215
collapsed = { false }
216
216
/>
217
- )
218
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( true )
219
- } )
217
+ ) ;
218
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( true ) ;
219
+ } ) ;
220
220
221
- it ( " empty object should not be expanded" , function ( ) {
222
- let src = { }
221
+ it ( ' empty object should not be expanded' , function ( ) {
222
+ let src = { } ;
223
223
224
224
const wrapper = shallow (
225
225
< JsonObject
226
226
src = { src }
227
227
theme = "rjv-default"
228
- namespace = { [ " root" ] }
228
+ namespace = { [ ' root' ] }
229
229
rjvId = { rjvId }
230
230
collapsed = { false }
231
231
/>
232
- )
233
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( false )
234
- } )
232
+ ) ;
233
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( false ) ;
234
+ } ) ;
235
235
236
- it ( " non-empty array should be expanded" , function ( ) {
237
- let src = [ 1 , 2 , 3 ]
236
+ it ( ' non-empty array should be expanded' , function ( ) {
237
+ let src = [ 1 , 2 , 3 ] ;
238
238
239
239
const wrapper = shallow (
240
240
< JsonObject
241
241
src = { src }
242
242
theme = "rjv-default"
243
- namespace = { [ " root" ] }
243
+ namespace = { [ ' root' ] }
244
244
rjvId = { rjvId }
245
245
collapsed = { false }
246
246
/>
247
- )
248
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( true )
249
- } )
247
+ ) ;
248
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( true ) ;
249
+ } ) ;
250
250
251
- it ( " empty array should not be expanded" , function ( ) {
252
- let src = [ ]
251
+ it ( ' empty array should not be expanded' , function ( ) {
252
+ let src = [ ] ;
253
253
254
254
const wrapper = shallow (
255
255
< JsonObject
256
256
src = { src }
257
257
theme = "rjv-default"
258
- namespace = { [ " root" ] }
258
+ namespace = { [ ' root' ] }
259
259
collapsed = { false }
260
+ indentWidth = { 1 }
260
261
/>
261
- )
262
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( false )
263
- } )
262
+ ) ;
263
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( false ) ;
264
+ } ) ;
264
265
265
- it ( " non-empty array should have ellipsis" , function ( ) {
266
- let src = [ 1 , 2 , 3 ]
266
+ it ( ' non-empty array should have ellipsis' , function ( ) {
267
+ let src = [ 1 , 2 , 3 ] ;
267
268
268
269
const wrapper = render (
269
270
< JsonObject
270
271
src = { src }
271
272
theme = "rjv-default"
272
- namespace = { [ " root" ] }
273
+ namespace = { [ ' root' ] }
273
274
rjvId = { rjvId }
274
275
collapsed = { true }
276
+ indentWidth = { 1 }
275
277
/>
276
- )
278
+ ) ;
277
279
278
- expect ( wrapper . find ( " .node-ellipsis" ) ) . to . have . length ( 1 )
279
- } )
280
+ expect ( wrapper . find ( ' .node-ellipsis' ) ) . to . have . length ( 1 ) ;
281
+ } ) ;
280
282
281
- it ( " empty array should not have ellipsis" , function ( ) {
282
- let src = [ ]
283
+ it ( ' empty array should not have ellipsis' , function ( ) {
284
+ let src = [ ] ;
283
285
284
286
const wrapper = render (
285
287
< JsonObject
286
288
src = { src }
287
289
theme = "rjv-default"
288
- namespace = { [ " root" ] }
290
+ namespace = { [ ' root' ] }
289
291
rjvId = { rjvId }
290
292
collapsed = { true }
293
+ indentWidth = { 1 }
291
294
/>
292
- )
295
+ ) ;
293
296
294
- expect ( wrapper . find ( " .node-ellipsis" ) ) . to . have . length ( 0 )
295
- } )
297
+ expect ( wrapper . find ( ' .node-ellipsis' ) ) . to . have . length ( 0 ) ;
298
+ } ) ;
296
299
297
- it ( " should collapse at shouldCollapse logic" , function ( ) {
298
- let src = { prop1 : 1 , prop2 : 2 , prop3 : 3 }
300
+ it ( ' should collapse at shouldCollapse logic' , function ( ) {
301
+ let src = { prop1 : 1 , prop2 : 2 , prop3 : 3 } ;
299
302
300
303
const wrapper = shallow (
301
304
< JsonObject
302
305
src = { src }
303
306
theme = "rjv-default"
304
- namespace = { [ " root" ] }
307
+ namespace = { [ ' root' ] }
305
308
collapsed = { false }
306
309
shouldCollapse = { ( ) => true }
307
310
/>
308
- )
311
+ ) ;
309
312
310
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( false )
311
- } )
313
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( false ) ;
314
+ } ) ;
312
315
313
- it ( " should expand based on shouldCollapse logic" , function ( ) {
314
- let src = { prop1 : 1 , prop2 : 2 , prop3 : 3 }
316
+ it ( ' should expand based on shouldCollapse logic' , function ( ) {
317
+ let src = { prop1 : 1 , prop2 : 2 , prop3 : 3 } ;
315
318
316
319
const wrapper = shallow (
317
320
< JsonObject
318
321
src = { src }
319
322
theme = "rjv-default"
320
- namespace = { [ " root" ] }
323
+ namespace = { [ ' root' ] }
321
324
collapsed = { false }
322
325
shouldCollapse = { ( ) => false }
326
+ indentWidth = { 1 }
323
327
/>
324
- )
328
+ ) ;
325
329
326
- expect ( wrapper . state ( " expanded" ) ) . to . equal ( true )
327
- } )
328
- it ( " sort object keys" , ( ) => {
330
+ expect ( wrapper . state ( ' expanded' ) ) . to . equal ( true ) ;
331
+ } ) ;
332
+ it ( ' sort object keys' , ( ) => {
329
333
let src = {
330
334
d : 'd' ,
331
335
b : 'b' ,
332
336
a : 'a' ,
333
- c : 'c' ,
334
- }
337
+ c : 'c'
338
+ } ;
335
339
336
340
const wrapper = render (
337
341
< JsonObject
338
342
src = { src }
339
343
theme = "rjv-default"
340
- namespace = { [ " root" ] }
344
+ namespace = { [ ' root' ] }
341
345
sortKeys = { true }
342
346
collapsed = { false }
343
347
shouldCollapse = { ( ) => false }
344
348
quotesOnKeys = { true }
349
+ indentWidth = { 1 }
345
350
/>
346
- )
351
+ ) ;
347
352
expect ( wrapper . text ( ) ) . to . equal ( '"":{"a":"a""b":"b""c":"c""d":"d"}' ) ;
348
- } )
353
+ } ) ;
349
354
350
- it ( " do not sort object keys" , ( ) => {
355
+ it ( ' do not sort object keys' , ( ) => {
351
356
let src = {
352
357
d : 'd' ,
353
358
b : 'b' ,
354
359
a : 'a' ,
355
- c : 'c' ,
356
- }
360
+ c : 'c'
361
+ } ;
357
362
358
363
const wrapper = render (
359
364
< JsonObject
360
365
src = { src }
361
366
theme = "rjv-default"
362
- namespace = { [ " root" ] }
367
+ namespace = { [ ' root' ] }
363
368
collapsed = { false }
364
369
shouldCollapse = { ( ) => false }
365
370
quotesOnKeys = { true }
371
+ indentWidth = { 1 }
366
372
/>
367
- )
373
+ ) ;
368
374
expect ( wrapper . text ( ) ) . to . equal ( '"":{"d":"d""b":"b""a":"a""c":"c"}' ) ;
369
- } )
370
- } )
375
+ } ) ;
376
+ } ) ;
0 commit comments