File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,12 @@ export default class extends React.PureComponent {
88 const namespace = [ props . name ] ;
99 let ObjectComponent = JsonObject ;
1010
11+ const size = Array . isArray ( props . src )
12+ ? props . src . length
13+ : Object . keys ( props . src ) . length ;
1114 if (
1215 props . groupArraysAfterLength &&
13- props . src . length > props . groupArraysAfterLength
16+ size > props . groupArraysAfterLength
1417 ) {
1518 ObjectComponent = ArrayGroup ;
1619 }
Original file line number Diff line number Diff line change @@ -117,4 +117,17 @@ describe("<Index />", function() {
117117 )
118118 expect ( wrapper . find ( ".array-group" ) ) . to . have . length ( 3 )
119119 } )
120+
121+ it ( "length is correct even if an object has a length property" , function ( ) {
122+ const wrapper = render (
123+ < Index
124+ src = { {
125+ first : "first property" ,
126+ second : "second property" ,
127+ length : 1000
128+ } }
129+ />
130+ )
131+ expect ( wrapper . find ( ".object-size" ) ) . to . have . length ( 1 )
132+ } )
120133} )
You can’t perform that action at this time.
0 commit comments