@@ -66,19 +66,19 @@ const testClickableNodeCollapsed = () => {
6666describe ( 'DataRender' , ( ) => {
6767 it ( 'should render booleans: true' , ( ) => {
6868 render ( < DataRender { ...commonProps } value = { { test : true } } /> ) ;
69- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
69+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
7070 expect ( screen . getByText ( 'true' ) ) . toBeInTheDocument ( ) ;
7171 } ) ;
7272
7373 it ( 'should render booleans: false' , ( ) => {
7474 render ( < DataRender { ...commonProps } value = { { test : false } } /> ) ;
75- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
75+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
7676 expect ( screen . getByText ( 'false' ) ) . toBeInTheDocument ( ) ;
7777 } ) ;
7878
7979 it ( 'should render strings' , ( ) => {
8080 render ( < DataRender { ...commonProps } value = { { test : 'string' } } /> ) ;
81- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
81+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
8282 expect ( screen . getByText ( `"string"` ) ) . toBeInTheDocument ( ) ;
8383 } ) ;
8484
@@ -90,7 +90,7 @@ describe('DataRender', () => {
9090 value = { { test : 'string' } }
9191 />
9292 ) ;
93- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
93+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
9494 expect ( screen . getByText ( `string` ) ) . toBeInTheDocument ( ) ;
9595 expect ( screen . queryByText ( `"string"` ) ) . not . toBeInTheDocument ( ) ;
9696 } ) ;
@@ -103,49 +103,71 @@ describe('DataRender', () => {
103103 value = { { test : 'string' } }
104104 />
105105 ) ;
106- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
106+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
107107 expect ( screen . getByText ( `"string"` ) ) . toBeInTheDocument ( ) ;
108108 } ) ;
109109
110+ it ( 'should render field names without quotes if quotesForFieldNames is undefined' , ( ) => {
111+ render (
112+ < DataRender
113+ { ...commonProps }
114+ style = { { ...defaultStyles , quotesForFieldNames : undefined } }
115+ value = { { test : 'string' } }
116+ />
117+ ) ;
118+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
119+ } ) ;
120+
121+ it ( 'should render field names with quotes if quotesForFieldNames is true' , ( ) => {
122+ render (
123+ < DataRender
124+ { ...commonProps }
125+ style = { { ...defaultStyles , quotesForFieldNames : true } }
126+ value = { { test : 'string' } }
127+ />
128+ ) ;
129+ expect ( screen . getByText ( / " t e s t " : / ) ) . toBeInTheDocument ( ) ;
130+ } ) ;
131+
110132 it ( 'should render numbers' , ( ) => {
111133 render ( < DataRender { ...commonProps } value = { { test : 42 } } /> ) ;
112- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
134+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
113135 expect ( screen . getByText ( '42' ) ) . toBeInTheDocument ( ) ;
114136 } ) ;
115137
116138 it ( 'should render bigints' , ( ) => {
117139 render ( < DataRender { ...commonProps } value = { { test : BigInt ( 42 ) } } /> ) ;
118- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
140+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
119141 expect ( screen . getByText ( '42n' ) ) . toBeInTheDocument ( ) ;
120142 } ) ;
121143
122144 it ( 'should render dates' , ( ) => {
123145 render ( < DataRender { ...commonProps } value = { { test : new Date ( 0 ) } } /> ) ;
124- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
146+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
125147 expect ( screen . getByText ( '1970-01-01T00:00:00.000Z' ) ) . toBeInTheDocument ( ) ;
126148 } ) ;
127149
128150 it ( 'should render nulls' , ( ) => {
129151 render ( < DataRender { ...commonProps } value = { { test : null } } /> ) ;
130- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
152+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
131153 expect ( screen . getByText ( 'null' ) ) . toBeInTheDocument ( ) ;
132154 } ) ;
133155
134156 it ( 'should render undefineds' , ( ) => {
135157 render ( < DataRender { ...commonProps } value = { { test : undefined } } /> ) ;
136- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
158+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
137159 expect ( screen . getByText ( 'undefined' ) ) . toBeInTheDocument ( ) ;
138160 } ) ;
139161
140162 it ( 'should render unknown types' , ( ) => {
141163 render ( < DataRender { ...commonProps } value = { { test : Symbol ( '2020' ) } } /> ) ;
142- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
164+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
143165 expect ( screen . getByText ( / 2 0 2 0 / ) ) . toBeInTheDocument ( ) ;
144166 } ) ;
145167
146168 it ( 'should render object with empty key string' , ( ) => {
147169 render ( < DataRender { ...commonProps } value = { { '' : 'empty key' } } /> ) ;
148- expect ( screen . getByText ( / " " / ) ) . toBeInTheDocument ( ) ;
170+ expect ( screen . getByText ( / " " : / ) ) . toBeInTheDocument ( ) ;
149171 expect ( screen . getByText ( / e m p t y k e y / ) ) . toBeInTheDocument ( ) ;
150172 } ) ;
151173
@@ -211,7 +233,7 @@ describe('DataRender', () => {
211233
212234 it ( 'should render nested objects' , ( ) => {
213235 render ( < DataRender { ...commonProps } value = { { obj : { test : 123 } } } /> ) ;
214- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
236+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
215237 expect ( screen . getByText ( '123' ) ) . toBeInTheDocument ( ) ;
216238 } ) ;
217239
@@ -224,7 +246,7 @@ describe('DataRender', () => {
224246 />
225247 ) ;
226248 expect ( screen . getByText ( / o b j / ) ) . toBeInTheDocument ( ) ;
227- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
249+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
228250 expect ( screen . queryByText ( '123' ) ) . not . toBeInTheDocument ( ) ;
229251 } ) ;
230252
@@ -237,36 +259,36 @@ describe('DataRender', () => {
237259 />
238260 ) ;
239261 expect ( screen . getByText ( / o b j / ) ) . toBeInTheDocument ( ) ;
240- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
262+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
241263 expect ( screen . queryByText ( '123' ) ) . not . toBeInTheDocument ( ) ;
242264
243265 rerender (
244266 < DataRender { ...commonProps } value = { { obj : { test : 123 } } } shouldExpandNode = { allExpanded } />
245267 ) ;
246268 expect ( screen . getByText ( / o b j / ) ) . toBeInTheDocument ( ) ;
247- expect ( screen . queryByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
269+ expect ( screen . queryByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
248270 expect ( screen . queryByText ( '123' ) ) . toBeInTheDocument ( ) ;
249271 } ) ;
250272
251273 it ( 'should render nested arrays collapsed' , ( ) => {
252274 render (
253275 < DataRender { ...commonProps } value = { { test : [ 123 ] } } shouldExpandNode = { collapseAllNested } />
254276 ) ;
255- expect ( screen . queryByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
277+ expect ( screen . queryByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
256278 expect ( screen . queryByText ( '123' ) ) . not . toBeInTheDocument ( ) ;
257279 } ) ;
258280
259281 it ( 'should render nested arrays collapsed and expand it once property changed' , ( ) => {
260282 const { rerender } = render (
261283 < DataRender { ...commonProps } value = { { test : [ 123 ] } } shouldExpandNode = { collapseAllNested } />
262284 ) ;
263- expect ( screen . queryByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
285+ expect ( screen . queryByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
264286 expect ( screen . queryByText ( '123' ) ) . not . toBeInTheDocument ( ) ;
265287
266288 rerender (
267289 < DataRender { ...commonProps } value = { { test : [ 123 ] } } shouldExpandNode = { allExpanded } />
268290 ) ;
269- expect ( screen . queryByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
291+ expect ( screen . queryByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
270292 expect ( screen . queryByText ( '123' ) ) . toBeInTheDocument ( ) ;
271293 } ) ;
272294
@@ -277,13 +299,13 @@ describe('DataRender', () => {
277299
278300 it ( 'should collapse and expand objects by clicking on icon' , ( ) => {
279301 render ( < DataRender { ...commonProps } value = { { test : true } } /> ) ;
280- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
302+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
281303 let buttons = testButtonsExpanded ( ) ;
282304 fireEvent . click ( buttons [ 0 ] ) ;
283- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
305+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
284306 buttons = testButtonsCollapsed ( ) ;
285307 fireEvent . click ( buttons [ 0 ] ) ;
286- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
308+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
287309 } ) ;
288310
289311 it ( 'should collapse and expand objects by clicking on node' , ( ) => {
@@ -296,25 +318,25 @@ describe('DataRender', () => {
296318 ) ;
297319
298320 // open the 'test' node by clicking the icon
299- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
321+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
300322 expect ( screen . queryByText ( / c h i l d / ) ) . not . toBeInTheDocument ( ) ;
301323 const buttons = testButtonsCollapsed ( ) ;
302324 fireEvent . click ( buttons [ 0 ] ) ;
303325 testClickableNodeCollapsed ( ) ;
304- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
326+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
305327 expect ( screen . queryByText ( / c h i l d / ) ) . not . toBeInTheDocument ( ) ;
306328 fireEvent . click ( buttons [ 0 ] ) ;
307- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
329+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
308330 expect ( screen . queryByText ( / c h i l d / ) ) . not . toBeInTheDocument ( ) ;
309331 } ) ;
310332
311333 it ( 'should expand objects by clicking on collapsed content' , ( ) => {
312334 render ( < DataRender { ...commonProps } value = { { test : true } } shouldExpandNode = { collapseAll } /> ) ;
313- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
335+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
314336 const buttons = testButtonsCollapsed ( ) ;
315337 fireEvent . click ( buttons [ 1 ] ) ;
316338 testButtonsExpanded ( ) ;
317- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
339+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
318340 } ) ;
319341
320342 it ( 'should collapse and expand arrays by clicking on icon' , ( ) => {
@@ -339,20 +361,20 @@ describe('DataRender', () => {
339361
340362 it ( 'should expand objects by pressing Spacebar on icon' , ( ) => {
341363 render ( < DataRender { ...commonProps } value = { { test : true } } shouldExpandNode = { collapseAll } /> ) ;
342- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
364+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
343365 const buttons = testButtonsCollapsed ( ) ;
344366 fireEvent . keyDown ( buttons [ 0 ] , { key : ' ' , code : 'Space' } ) ;
345367 testButtonsExpanded ( ) ;
346- expect ( screen . getByText ( / t e s t / ) ) . toBeInTheDocument ( ) ;
368+ expect ( screen . getByText ( / t e s t : / ) ) . toBeInTheDocument ( ) ;
347369 } ) ;
348370
349371 it ( 'should not expand objects by pressing other keys on icon' , ( ) => {
350372 render ( < DataRender { ...commonProps } value = { { test : true } } shouldExpandNode = { collapseAll } /> ) ;
351- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
373+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
352374 const buttons = testButtonsCollapsed ( ) ;
353375 fireEvent . keyDown ( buttons [ 0 ] , { key : 'Enter' , code : 'Enter' } ) ;
354376 testButtonsCollapsed ( ) ;
355- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
377+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
356378 } ) ;
357379
358380 it ( 'should expand arrays by pressing Spacebar on icon' , ( ) => {
@@ -373,11 +395,11 @@ describe('DataRender', () => {
373395 < DataRender { ...commonProps } value = { [ 'test' , 'array' ] } shouldExpandNode = { collapseAll } />
374396 ) ;
375397 const buttons = testButtonsCollapsed ( ) ;
376- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
398+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
377399 expect ( screen . queryByText ( / a r r a y / ) ) . not . toBeInTheDocument ( ) ;
378400 fireEvent . keyDown ( buttons [ 0 ] , { key : 'Enter' , code : 'Enter' } ) ;
379401 testButtonsCollapsed ( ) ;
380- expect ( screen . queryByText ( / t e s t / ) ) . not . toBeInTheDocument ( ) ;
402+ expect ( screen . queryByText ( / t e s t : / ) ) . not . toBeInTheDocument ( ) ;
381403 expect ( screen . queryByText ( / a r r a y / ) ) . not . toBeInTheDocument ( ) ;
382404 } ) ;
383405} ) ;
0 commit comments