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 {
8
8
const namespace = [ props . name ] ;
9
9
let ObjectComponent = JsonObject ;
10
10
11
+ const size = Array . isArray ( props . src )
12
+ ? props . src . length
13
+ : Object . keys ( props . src ) . length ;
11
14
if (
12
15
props . groupArraysAfterLength &&
13
- props . src . length > props . groupArraysAfterLength
16
+ size > props . groupArraysAfterLength
14
17
) {
15
18
ObjectComponent = ArrayGroup ;
16
19
}
Original file line number Diff line number Diff line change @@ -117,4 +117,17 @@ describe("<Index />", function() {
117
117
)
118
118
expect ( wrapper . find ( ".array-group" ) ) . to . have . length ( 3 )
119
119
} )
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
+ } )
120
133
} )
You can’t perform that action at this time.
0 commit comments