diff options
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | app/assets/javascripts/vue_shared/components/stacked_progress_bar.vue | 4 | ||||
-rw-r--r-- | spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 722c5043c4a..45d0dbf1c7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: RAILS_ENV: "test" NODE_ENV: "test" SIMPLECOV: "true" - GIT_DEPTH: "50" + GIT_DEPTH: "20" GIT_SUBMODULE_STRATEGY: "none" GET_SOURCES_ATTEMPTS: "3" KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/report-master.json diff --git a/app/assets/javascripts/vue_shared/components/stacked_progress_bar.vue b/app/assets/javascripts/vue_shared/components/stacked_progress_bar.vue index af4eb2de7f8..ea564d1b2f2 100644 --- a/app/assets/javascripts/vue_shared/components/stacked_progress_bar.vue +++ b/app/assets/javascripts/vue_shared/components/stacked_progress_bar.vue @@ -71,6 +71,10 @@ export default { }, methods: { getPercent(count) { + if (!this.totalCount) { + return 0; + } + const percent = roundOffFloat((count / this.totalCount) * 100, 1); if (percent > 0 && percent < 1) { return '< 1'; diff --git a/spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js b/spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js index e4db67f5b18..f226dabb8a0 100644 --- a/spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js +++ b/spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js @@ -53,6 +53,12 @@ describe('StackedProgressBarComponent', () => { it('returns percentage as `< 1` from provided count based on `totalCount` when evaluated value is less than 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', () => { |