Commit 60b16f46 authored by Kushal Pandya's avatar Kushal Pandya

Show `< 1%` when percent value evaluated is less than 1

parent 3c80adf5
......@@ -71,7 +71,11 @@ export default {
},
methods: {
getPercent(count) {
return roundOffFloat((count / this.totalCount) * 100, 1);
const percent = roundOffFloat((count / this.totalCount) * 100, 1);
if (percent > 0 && percent < 1) {
return '< 1';
}
return percent;
},
barStyle(percent) {
return `width: ${percent}%;`;
......
......@@ -44,7 +44,11 @@ describe('StackedProgressBarComponent', () => {
});
it('returns percentage with decimal place from provided count based on `totalCount`', () => {
expect(vm.getPercent(10)).toBe(0.2);
expect(vm.getPercent(67)).toBe(1.3);
});
it('returns percentage as `< 1` from provided count based on `totalCount` when evaluated value is less than 1', () => {
expect(vm.getPercent(10)).toBe('< 1');
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment