Welcome to mirror list, hosted at ThFree Co, Russian Federation.

runner_single_stat_spec.js « stat « components « runner « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cad61f260126d71088e703fc102e33d9c045ded0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { GlSingleStat } from '@gitlab/ui/dist/charts';
import { shallowMount } from '@vue/test-utils';
import RunnerSingleStat from '~/ci/runner/components/stat/runner_single_stat.vue';
import RunnerCount from '~/ci/runner/components/stat/runner_count.vue';
import { INSTANCE_TYPE, GROUP_TYPE } from '~/ci/runner/constants';

describe('RunnerStats', () => {
  let wrapper;

  const findRunnerCount = () => wrapper.findComponent(RunnerCount);
  const findGlSingleStat = () => wrapper.findComponent(GlSingleStat);

  const createComponent = ({ props = {}, count, mountFn = shallowMount, ...options } = {}) => {
    wrapper = mountFn(RunnerSingleStat, {
      propsData: {
        scope: INSTANCE_TYPE,
        title: 'My title',
        variables: {},
        ...props,
      },
      stubs: {
        RunnerCount: {
          props: ['scope', 'variables', 'skip'],
          render() {
            return this.$scopedSlots.default({
              count,
            });
          },
        },
      },
      ...options,
    });
  };

  afterEach(() => {
    wrapper.destroy();
  });

  it.each`
    case              | count   | value
    ${'number'}       | ${99}   | ${'99'}
    ${'long number'}  | ${1000} | ${'1,000'}
    ${'empty number'} | ${null} | ${'-'}
  `('formats $case', ({ count, value }) => {
    createComponent({ count });

    expect(findGlSingleStat().props('value')).toBe(value);
  });

  it('Passes runner count props', () => {
    const props = {
      scope: GROUP_TYPE,
      variables: { paused: true },
      skip: true,
    };

    createComponent({ props });

    expect(findRunnerCount().props()).toEqual(props);
  });
});