summaryrefslogtreecommitdiff
path: root/spec/frontend/ci/runner/components/stat/runner_stats_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/ci/runner/components/stat/runner_stats_spec.js')
-rw-r--r--spec/frontend/ci/runner/components/stat/runner_stats_spec.js53
1 files changed, 37 insertions, 16 deletions
diff --git a/spec/frontend/ci/runner/components/stat/runner_stats_spec.js b/spec/frontend/ci/runner/components/stat/runner_stats_spec.js
index daebf3df050..3d45674d106 100644
--- a/spec/frontend/ci/runner/components/stat/runner_stats_spec.js
+++ b/spec/frontend/ci/runner/components/stat/runner_stats_spec.js
@@ -16,6 +16,23 @@ describe('RunnerStats', () => {
const findSingleStats = () => wrapper.findAllComponents(RunnerSingleStat);
+ const RunnerCountStub = {
+ props: ['variables'],
+ render() {
+ // return a count for each status
+ const mockCounts = {
+ undefined: 6, // no status returns "all"
+ [STATUS_ONLINE]: 3,
+ [STATUS_OFFLINE]: 2,
+ [STATUS_STALE]: 1,
+ };
+
+ return this.$scopedSlots.default({
+ count: mockCounts[this.variables.status],
+ });
+ },
+ };
+
const createComponent = ({ props = {}, mountFn = shallowMount, ...options } = {}) => {
wrapper = mountFn(RunnerStats, {
propsData: {
@@ -23,6 +40,9 @@ describe('RunnerStats', () => {
variables: {},
...props,
},
+ stubs: {
+ RunnerCount: RunnerCountStub,
+ },
...options,
});
};
@@ -32,24 +52,8 @@ describe('RunnerStats', () => {
});
it('Displays all the stats', () => {
- const mockCounts = {
- [STATUS_ONLINE]: 3,
- [STATUS_OFFLINE]: 2,
- [STATUS_STALE]: 1,
- };
-
createComponent({
mountFn: mount,
- stubs: {
- RunnerCount: {
- props: ['variables'],
- render() {
- return this.$scopedSlots.default({
- count: mockCounts[this.variables.status],
- });
- },
- },
- },
});
const text = wrapper.text();
@@ -78,4 +82,21 @@ describe('RunnerStats', () => {
expect(stat.props('variables')).toMatchObject(mockVariables);
});
});
+
+ it('Does not display counts when total is 0', () => {
+ createComponent({
+ mountFn: mount,
+ stubs: {
+ RunnerCount: {
+ render() {
+ return this.$scopedSlots.default({
+ count: 0,
+ });
+ },
+ },
+ },
+ });
+
+ expect(wrapper.html()).toBe('');
+ });
});