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

runner_tags_spec.js « components « runner « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c6bfabdb18a3b2bde4a1030c9dd262a004d55fee (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
import { GlBadge } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import RunnerTags from '~/runner/components/runner_tags.vue';

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

  const findBadge = () => wrapper.findComponent(GlBadge);
  const findBadgesAt = (i = 0) => wrapper.findAllComponents(GlBadge).at(i);

  const createComponent = ({ props = {} } = {}) => {
    wrapper = mount(RunnerTags, {
      propsData: {
        tagList: ['tag1', 'tag2'],
        ...props,
      },
    });
  };

  beforeEach(() => {
    createComponent();
  });

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

  it('Displays tags text', () => {
    expect(wrapper.text()).toMatchInterpolatedText('tag1 tag2');

    expect(findBadgesAt(0).text()).toBe('tag1');
    expect(findBadgesAt(1).text()).toBe('tag2');
  });

  it('Displays tags with correct style', () => {
    expect(findBadge().props('size')).toBe('sm');
  });

  it('Displays tags with md size', () => {
    createComponent({
      props: { size: 'md' },
    });

    expect(findBadge().props('size')).toBe('md');
  });

  it('Is empty when there are no tags', () => {
    createComponent({
      props: { tagList: null },
    });

    expect(wrapper.html()).toEqual('');
  });
});