Skip to content
Snippets Groups Projects
Commit d6ec3ac6 authored by Kushal Pandya's avatar Kushal Pandya
Browse files

Use `roundOffFloat` method to show decimal places in progressbar

parent b4878814
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
<script>
import { roundOffFloat } from '~/lib/utils/common_utils';
import tooltip from '~/vue_shared/directives/tooltip';
 
export default {
Loading
Loading
@@ -70,7 +71,7 @@ export default {
},
methods: {
getPercent(count) {
return Math.ceil((count / this.totalCount) * 100);
return roundOffFloat((count / this.totalCount) * 100, 1);
},
barStyle(percent) {
return `width: ${percent}%;`;
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@
.status-neutral,
.status-red, {
height: 100%;
min-width: 30px;
min-width: 40px;
padding: 0 5px;
font-size: $tooltip-font-size;
font-weight: normal;
Loading
Loading
Loading
Loading
@@ -10,9 +10,9 @@ const createComponent = (config) => {
successLabel: 'Synced',
failureLabel: 'Failed',
neutralLabel: 'Out of sync',
successCount: 10,
failureCount: 5,
totalCount: 20,
successCount: 25,
failureCount: 10,
totalCount: 5000,
}, config);
 
return mountComponent(Component, defaultConfig);
Loading
Loading
@@ -32,7 +32,7 @@ describe('StackedProgressBarComponent', () => {
describe('computed', () => {
describe('neutralCount', () => {
it('returns neutralCount based on totalCount, successCount and failureCount', () => {
expect(vm.neutralCount).toBe(5); // 20 - 10 - 5
expect(vm.neutralCount).toBe(4965); // 5000 - 25 - 10
});
});
});
Loading
Loading
@@ -40,7 +40,11 @@ describe('StackedProgressBarComponent', () => {
describe('methods', () => {
describe('getPercent', () => {
it('returns percentage from provided count based on `totalCount`', () => {
expect(vm.getPercent(10)).toBe(50);
expect(vm.getPercent(500)).toBe(10);
});
it('returns percentage with decimal place from provided count based on `totalCount`', () => {
expect(vm.getPercent(10)).toBe(0.2);
});
});
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment