Commit 6a83747f authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '7707-fix-infinity-progress' into 'master'

Fix Infinity % / Infinity % on Stacked Progress Bar

Closes #7707

See merge request gitlab-org/gitlab!21437
parents 609e59f1 b9e9f856
...@@ -71,6 +71,10 @@ export default { ...@@ -71,6 +71,10 @@ export default {
}, },
methods: { methods: {
getPercent(count) { getPercent(count) {
if (!this.totalCount) {
return 0;
}
const percent = roundOffFloat((count / this.totalCount) * 100, 1); const percent = roundOffFloat((count / this.totalCount) * 100, 1);
if (percent > 0 && percent < 1) { if (percent > 0 && percent < 1) {
return '< 1'; return '< 1';
......
---
title: Fix Infinity % / Infinity % on Stacked Progress Bar
merge_request: 21437
author:
type: fixed
...@@ -53,6 +53,12 @@ describe('StackedProgressBarComponent', () => { ...@@ -53,6 +53,12 @@ describe('StackedProgressBarComponent', () => {
it('returns percentage as `< 1` from provided count based on `totalCount` when evaluated value is less than 1', () => { it('returns percentage as `< 1` from provided count based on `totalCount` when evaluated value is less than 1', () => {
expect(vm.getPercent(10)).toBe('< 1'); expect(vm.getPercent(10)).toBe('< 1');
}); });
it('returns 0 if totalCount is falsy', () => {
vm = createComponent({ totalCount: 0 });
expect(vm.getPercent(100)).toBe(0);
});
}); });
describe('barStyle', () => { describe('barStyle', () => {
......
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