Skip to content

Commit f00ce38

Browse files
committed
fix(starRating): Retrieve the correct count and use numericRefinement
Closes #615
1 parent ce954b8 commit f00ce38

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/widgets/star-rating/__tests__/star-rating-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ describe('starRating()', () => {
104104
});
105105

106106
it('hide the count==0 when there is a refinement', () => {
107-
helper.getRefinements = sinon.stub().returns([{value: '2'}]);
108-
results.getFacetValues = sinon.stub().returns([{name: '2', count: 42}]);
107+
helper.getRefinements = sinon.stub().returns([{value: '1'}]);
108+
results.getFacetValues = sinon.stub().returns([{name: '1', count: 42}]);
109109
widget.render({helper, results});
110110
expect(ReactDOM.render.calledOnce).toBe(true, 'ReactDOM.render called once');
111111
expect(ReactDOM.render.firstCall.args[0].props.facetValues).toEqual([
112112
{
113113
count: 42,
114114
isRefined: true,
115-
name: '2',
116-
stars: [true, true, false, false, false],
115+
name: '1',
116+
stars: [true, false, false, false, false],
117117
labels: defaultLabels
118118
}
119119
]);

src/widgets/star-rating/star-rating.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ function starRating({
9797
if (!val || val > max - 1) {
9898
return;
9999
}
100-
allValues[val] += facet.count;
100+
for (let v = val; v >= 1; --v) {
101+
allValues[v] += facet.count;
102+
}
101103
});
102104
let refinedStar = this._getRefinedStar(helper);
103105
for (let star = max - 1; star >= 1; --star) {

0 commit comments

Comments
 (0)