Commit 14e52653 authored by Phil Hughes's avatar Phil Hughes

Merge branch '4582-fix-incorrect-neutral-count' into 'master'

Fix neutralCount computation to prevent negative values

Closes #4582

See merge request gitlab-org/gitlab-ee!4044
parents bbf9174e 4c1652cf
......@@ -37,6 +37,9 @@ export default {
},
},
computed: {
neutralCount() {
return this.totalCount - this.successCount - this.failureCount;
},
successPercent() {
return this.getPercent(this.successCount);
},
......@@ -56,14 +59,13 @@ export default {
return this.getTooltip(this.failureLabel, this.failureCount);
},
neutralPercent() {
return 100 - this.successPercent - this.failurePercent;
return this.getPercent(this.neutralCount);
},
neutralBarStyle() {
return this.barStyle(this.neutralPercent);
},
neutralTooltip() {
const neutralCount = this.totalCount - this.successCount - this.failureCount;
return this.getTooltip(this.neutralLabel, neutralCount);
return this.getTooltip(this.neutralLabel, this.neutralCount);
},
},
methods: {
......
---
title: Fix neutralCount computation to prevent negative values
merge_request: 4044
author:
type: fixed
......@@ -29,6 +29,14 @@ describe('StackedProgressBarComponent', () => {
vm.$destroy();
});
describe('computed', () => {
describe('neutralCount', () => {
it('returns neutralCount based on totalCount, successCount and failureCount', () => {
expect(vm.neutralCount).toBe(5); // 20 - 10 - 5
});
});
});
describe('methods', () => {
describe('getPercent', () => {
it('returns percentage from provided count based on `totalCount`', () => {
......
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