Skip to content

Commit

Permalink
fix(priceRanges): avoid displaying solo ranges (#1544)
Browse files Browse the repository at this point in the history
fixes #1536
  • Loading branch information
vvo authored and bobylito committed Nov 14, 2016
1 parent 6cf61df commit ff396f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/widgets/price-ranges/__tests__/generate-ranges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ describe('generateRanges()', () => {
const stats = {min: 20, max: 20, avg: 20, sum: 20};
expect(generateRanges(stats)).toEqual([]);
});

it('should not generate ranges', () => {
const stats = {min: 6765, max: 6765, avg: 6765, sum: 6765};
expect(generateRanges(stats)).toEqual([]);
});
});
5 changes: 5 additions & 0 deletions src/widgets/price-ranges/generate-ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function round(v, precision) {
}

function generateRanges(stats) {
// cannot compute any range
if (stats.min === stats.max) {
return [];
}

let precision;
if (stats.avg < 100) {
precision = 1;
Expand Down

0 comments on commit ff396f0

Please sign in to comment.