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

integration_help_text_spec.js « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c0e8b719007e4dce8d1aa23da59678e714c3380e (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
import { GlIcon, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';

import IntegrationHelpText from '~/vue_shared/components/integrations_help_text.vue';

describe('IntegrationHelpText component', () => {
  let wrapper;
  const defaultProps = {
    message: 'Click %{linkStart}Bar%{linkEnd}!',
    messageUrl: 'http://bar.com',
  };

  function createComponent(props = {}) {
    return shallowMount(IntegrationHelpText, {
      propsData: {
        ...defaultProps,
        ...props,
      },
      stubs: {
        GlSprintf,
      },
    });
  }

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

  it('should use the gl components', () => {
    wrapper = createComponent();

    expect(wrapper.find(GlSprintf).exists()).toBe(true);
    expect(wrapper.find(GlIcon).exists()).toBe(true);
    expect(wrapper.find(GlLink).exists()).toBe(true);
  });

  it('should render the help text', () => {
    wrapper = createComponent();

    expect(wrapper.element).toMatchSnapshot();
  });

  it('should not use the gl-link and gl-icon components', () => {
    wrapper = createComponent({ message: 'Click nowhere!' });

    expect(wrapper.find(GlSprintf).exists()).toBe(true);
    expect(wrapper.find(GlIcon).exists()).toBe(false);
    expect(wrapper.find(GlLink).exists()).toBe(false);
  });

  it('should not render the link when start and end is not provided', () => {
    wrapper = createComponent({ message: 'Click nowhere!' });

    expect(wrapper.element).toMatchSnapshot();
  });
});