File tree 2 files changed +26
-3
lines changed
components/RefinementList
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,11 @@ class RefinementList extends React.Component {
35
35
[ this . props . cssClasses . active ] : facetValue . isRefined
36
36
} ) ;
37
37
38
+ let key = facetValue [ this . props . facetNameKey ] + '/' + facetValue . isRefined + '/' + facetValue . count ;
38
39
return (
39
40
< div
40
41
className = { cssClassItem }
41
- key = { facetValue [ this . props . facetNameKey ] }
42
+ key = { key }
42
43
onClick = { this . handleClick . bind ( this , facetValue [ this . props . facetNameKey ] ) }
43
44
>
44
45
< Template data = { templateData } templateKey = "item" { ...this . props . templateProps } />
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ describe('RefinementList', () => {
29
29
data : {
30
30
cssClasses : {
31
31
list : 'list' ,
32
- item : 'item'
32
+ item : 'item' ,
33
+ active : 'active'
33
34
}
34
35
}
35
36
} ;
@@ -55,6 +56,26 @@ describe('RefinementList', () => {
55
56
</ div >
56
57
</ div >
57
58
) ;
59
+ expect ( out . props . children [ 0 ] . key ) . toEqual ( 'facet1/undefined/undefined' ) ;
60
+ expect ( out . props . children [ 1 ] . key ) . toEqual ( 'facet2/undefined/undefined' ) ;
61
+ } ) ;
62
+
63
+ it ( 'should render default list highlighted' , ( ) => {
64
+ let out = render ( { facetValues : [ { name : 'facet1' , isRefined : true , count : 42 } ] } ) ;
65
+ let activeTemplateProp = { ...templateProps } ;
66
+ activeTemplateProp . data . count = 42 ;
67
+ activeTemplateProp . data . isRefined = true ;
68
+ expect ( out ) . toEqualJSX (
69
+ < div { ...parentListProps } >
70
+ < div className = "item active" onClick = { itemProps . onClick } >
71
+ < Template
72
+ { ...activeTemplateProp }
73
+ data = { { ...templateProps . data , name : 'facet1' } }
74
+ />
75
+ </ div >
76
+ </ div >
77
+ ) ;
78
+ expect ( out . props . children [ 0 ] . key ) . toEqual ( 'facet1/true/42' ) ;
58
79
} ) ;
59
80
60
81
context ( 'sublist' , ( ) => {
@@ -127,7 +148,8 @@ describe('RefinementList', () => {
127
148
return {
128
149
cssClasses : {
129
150
list : 'list' ,
130
- item : 'item'
151
+ item : 'item' ,
152
+ active : 'active'
131
153
} ,
132
154
facetValues : [
133
155
{ name : 'facet1' } ,
You can’t perform that action at this time.
0 commit comments