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

sidebar_detail_row_spec.js « components « jobs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d2680608abb7def778dfc8a7f236ce8747751fd (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
import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import SidebarDetailRow from '~/jobs/components/sidebar_detail_row.vue';

describe('Sidebar detail row', () => {
  let wrapper;

  const title = 'this is the title';
  const value = 'this is the value';
  const helpUrl = 'https://docs.gitlab.com/runner/register/index.html';

  const findHelpLink = () => wrapper.findComponent(GlLink);

  const createComponent = (props) => {
    wrapper = shallowMount(SidebarDetailRow, {
      propsData: {
        ...props,
      },
    });
  };

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

  describe('with title/value and without helpUrl', () => {
    beforeEach(() => {
      createComponent({ title, value });
    });

    it('should render the provided title and value', () => {
      expect(wrapper.text()).toBe(`${title}: ${value}`);
    });

    it('should not render the help link', () => {
      expect(findHelpLink().exists()).toBe(false);
    });
  });

  describe('when helpUrl provided', () => {
    beforeEach(() => {
      createComponent({
        helpUrl,
        title,
        value,
      });
    });

    it('should render the help link', () => {
      expect(findHelpLink().exists()).toBe(true);
      expect(findHelpLink().attributes('href')).toBe(helpUrl);
    });
  });
});