@@ -21,12 +21,10 @@ describe('Json Component', () => {
2121 } )
2222
2323 it . for ( [
24- [ 'foo' , 'bar' ] ,
2524 [ ] ,
2625 [ 1 , 2 , 3 ] ,
27- [ 1 , 'foo' , null ] ,
2826 Array . from ( { length : 101 } , ( _ , i ) => i ) ,
29- ] ) ( 'collapses any array' , ( array ) => {
27+ ] ) ( 'collapses any array with primitives ' , ( array ) => {
3028 const { getByRole } = render ( < Json json = { array } /> )
3129 expect ( getByRole ( 'treeitem' ) . ariaExpanded ) . toBe ( 'false' )
3230 } )
@@ -67,14 +65,22 @@ describe('Json Component', () => {
6765 it . for ( [
6866 [ 1 , 'foo' , [ 1 , 2 , 3 ] ] ,
6967 [ 1 , 'foo' , { nested : true } ] ,
70- ] ) ( 'expands short arrays with non-primitive values ' , ( arr ) => {
68+ ] ) ( 'expands short arrays with inner arrays or objects ' , ( arr ) => {
7169 const { getAllByRole } = render ( < Json json = { arr } /> )
7270 const treeItems = getAllByRole ( 'treeitem' )
7371 expect ( treeItems . length ) . toBe ( 2 )
7472 expect ( treeItems [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) // the root
7573 expect ( treeItems [ 1 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) // the non-primitive value (object/array)
7674 } )
7775
76+ it . for ( [
77+ [ 'foo' , 'bar' ] ,
78+ [ 1 , 'foo' , null ] ,
79+ ] ) ( 'expands short arrays with strings' , ( arr ) => {
80+ const { getByRole } = render ( < Json json = { arr } /> )
81+ expect ( getByRole ( 'treeitem' ) . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
82+ } )
83+
7884 it . for ( [
7985 { obj : [ 314 , null ] } ,
8086 { obj : { nested : true } } ,
0 commit comments