Skip to content

Commit ff396f0

Browse files
vvobobylito
authored andcommitted
fix(priceRanges): avoid displaying solo ranges (#1544)
fixes #1536
1 parent 6cf61df commit ff396f0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/widgets/price-ranges/__tests__/generate-ranges-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ describe('generateRanges()', () => {
5757
const stats = {min: 20, max: 20, avg: 20, sum: 20};
5858
expect(generateRanges(stats)).toEqual([]);
5959
});
60+
61+
it('should not generate ranges', () => {
62+
const stats = {min: 6765, max: 6765, avg: 6765, sum: 6765};
63+
expect(generateRanges(stats)).toEqual([]);
64+
});
6065
});

src/widgets/price-ranges/generate-ranges.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ function round(v, precision) {
77
}
88

99
function generateRanges(stats) {
10+
// cannot compute any range
11+
if (stats.min === stats.max) {
12+
return [];
13+
}
14+
1015
let precision;
1116
if (stats.avg < 100) {
1217
precision = 1;

0 commit comments

Comments
 (0)