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

sidebar_detail_row_spec.js « job « components « jobs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd27004816a7c39fe5c8c2172115226743ca243c (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
62
63
64
65
66
67
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import SidebarDetailRow from '~/jobs/components/job/sidebar/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 path = 'path/to/value';

  const findHelpLink = () => wrapper.findByTestId('job-sidebar-help-link');
  const findValueLink = () => wrapper.findByTestId('job-sidebar-value-link');

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

  describe('with title/value and without helpUrl/path', () => {
    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);
    });

    it('should not render the value link', () => {
      expect(findValueLink().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);
    });
  });

  describe('when path is provided', () => {
    it('should render link to value', () => {
      createComponent({
        path,
        title,
        value,
      });

      expect(findValueLink().attributes('href')).toBe(path);
    });
  });
});