replace missing round function in d3 to fix MapBox (#6444)

* replace missing round function in d3

* added unit test

* fixed linting
This commit is contained in:
aboganas
2018-11-28 08:34:27 +03:00
committed by Maxime Beauchemin
parent 2931baa294
commit 71a713dcec
4 changed files with 29 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import {
d3TimeFormatPreset,
defaultNumberFormatter,
mainMetric,
roundDecimal,
} from '../../../src/modules/utils';
describe('utils', () => {
@@ -99,4 +100,11 @@ describe('utils', () => {
expect(mainMetric(metrics)).toBe('foo');
});
});
describe('roundDecimal', () => {
it('rounding method to limit the number of decimal digits', () => {
expect(roundDecimal(1.139, 2)).toBe(1.14);
expect(roundDecimal(1.13929, 3)).toBe(1.139);
expect(roundDecimal(1.13929)).toBe(1);
});
});
});