@@ -22,12 +22,10 @@ describe('Json Component', () => {
2222 } )
2323
2424 it . for ( [
25- [ 'foo' , 'bar' ] ,
2625 [ ] ,
2726 [ 1 , 2 , 3 ] ,
28- [ 1 , 'foo' , null ] ,
2927 Array . from ( { length : 101 } , ( _ , i ) => i ) ,
30- ] ) ( 'collapses any array' , ( array ) => {
28+ ] ) ( 'collapses any array with primitives ' , ( array ) => {
3129 const { getByRole } = render ( < Json json = { array } /> )
3230 expect ( getByRole ( 'treeitem' ) . ariaExpanded ) . toBe ( 'false' )
3331 } )
@@ -68,14 +66,22 @@ describe('Json Component', () => {
6866 it . for ( [
6967 [ 1 , 'foo' , [ 1 , 2 , 3 ] ] ,
7068 [ 1 , 'foo' , { nested : true } ] ,
71- ] ) ( 'expands short arrays with non-primitive values ' , ( arr ) => {
69+ ] ) ( 'expands short arrays with inner arrays or objects ' , ( arr ) => {
7270 const { getAllByRole } = render ( < Json json = { arr } /> )
7371 const treeItems = getAllByRole ( 'treeitem' )
7472 expect ( treeItems . length ) . toBe ( 2 )
7573 expect ( treeItems [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) // the root
7674 expect ( treeItems [ 1 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) // the non-primitive value (object/array)
7775 } )
7876
77+ it . for ( [
78+ [ 'foo' , 'bar' ] ,
79+ [ 1 , 'foo' , null ] ,
80+ ] ) ( 'expands short arrays with strings' , ( arr ) => {
81+ const { getByRole } = render ( < Json json = { arr } /> )
82+ expect ( getByRole ( 'treeitem' ) . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
83+ } )
84+
7985 it . for ( [
8086 { obj : [ 314 , null ] } ,
8187 { obj : { nested : true } } ,
0 commit comments