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

clone_dropdown_item_spec.js « clone_dropdown « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0dfa084f3e390d2ad3ce2756b29f82e8f180d67 (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
import { GlButton, GlFormGroup, GlFormInputGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import CloneDropdownItem from '~/vue_shared/components/clone_dropdown/clone_dropdown_item.vue';

describe('Clone Dropdown Button', () => {
  let wrapper;
  const link = 'ssh://foo.bar';
  const label = 'SSH';
  const qaSelector = 'some-selector';
  const defaultPropsData = {
    link,
    label,
    qaSelector,
  };

  const findCopyButton = () => wrapper.findComponent(GlButton);

  const createComponent = (propsData = defaultPropsData) => {
    wrapper = shallowMount(CloneDropdownItem, {
      propsData,
      stubs: {
        GlFormInputGroup,
      },
    });
  };

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

  describe('default', () => {
    it('sets form group label', () => {
      expect(wrapper.findComponent(GlFormGroup).attributes('label')).toBe(label);
    });

    it('sets form input group link', () => {
      expect(wrapper.findComponent(GlFormInputGroup).props('value')).toBe(link);
    });

    it('sets the copy tooltip text', () => {
      expect(findCopyButton().attributes('title')).toBe('Copy URL');
    });

    it('sets the copy tooltip link', () => {
      expect(findCopyButton().attributes('data-clipboard-text')).toBe(link);
    });

    it('sets the qa selector', () => {
      expect(findCopyButton().attributes('data-qa-selector')).toBe(qaSelector);
    });
  });
});