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

project_setting_row_spec.js « components « permissions « shared « projects « pages « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6230809a6aa6354b4e54145500d8c66cc5e62c2e (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
import { shallowMount } from '@vue/test-utils';

import { nextTick } from 'vue';
import projectSettingRow from '~/pages/projects/shared/permissions/components/project_setting_row.vue';

describe('Project Setting Row', () => {
  let wrapper;

  const mountComponent = (customProps = {}) => {
    const propsData = { ...customProps };
    return shallowMount(projectSettingRow, { propsData });
  };

  beforeEach(() => {
    wrapper = mountComponent();
  });

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

  it('should show the label if it is set', async () => {
    wrapper.setProps({ label: 'Test label' });

    await nextTick();
    expect(wrapper.find('label').text()).toEqual('Test label');
  });

  it('should hide the label if it is not set', () => {
    expect(wrapper.find('label').exists()).toBe(false);
  });

  it('should show the help icon with the correct help path if it is set', async () => {
    wrapper.setProps({ label: 'Test label', helpPath: '/123' });

    await nextTick();
    const link = wrapper.find('a');

    expect(link.exists()).toBe(true);
    expect(link.attributes().href).toEqual('/123');
  });

  it('should hide the help icon if no help path is set', async () => {
    wrapper.setProps({ label: 'Test label' });

    await nextTick();
    expect(wrapper.find('a').exists()).toBe(false);
  });

  it('should show the help text if it is set', async () => {
    wrapper.setProps({ helpText: 'Test text' });

    await nextTick();
    expect(wrapper.find('span').text()).toEqual('Test text');
  });

  it('should hide the help text if it is set', () => {
    expect(wrapper.find('span').exists()).toBe(false);
  });
});