summaryrefslogtreecommitdiff
path: root/spec/frontend/issue_show/components/pinned_links_spec.js
blob: 007ad4c9a1b752d9f6124ae82a3fb83679fb6d76 (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 { shallowMount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui';
import PinnedLinks from '~/issue_show/components/pinned_links.vue';

const plainZoomUrl = 'https://zoom.us/j/123456789';
const plainStatusUrl = 'https://status.com';

describe('PinnedLinks', () => {
  let wrapper;

  const findLinks = () => wrapper.findAll(GlLink);

  const createComponent = props => {
    wrapper = shallowMount(PinnedLinks, {
      propsData: {
        zoomMeetingUrl: '',
        publishedIncidentUrl: '',
        ...props,
      },
    });
  };

  it('displays Zoom link', () => {
    createComponent({
      zoomMeetingUrl: `<a href="${plainZoomUrl}">Zoom</a>`,
    });

    expect(
      findLinks()
        .at(0)
        .text(),
    ).toBe('Join Zoom meeting');
  });

  it('displays Status link', () => {
    createComponent({
      publishedIncidentUrl: `<a href="${plainStatusUrl}">Status</a>`,
    });

    expect(
      findLinks()
        .at(0)
        .text(),
    ).toBe('Published on status page');
  });

  it('does not render if there are no links', () => {
    createComponent({
      zoomMeetingUrl: '',
      publishedIncidentUrl: '',
    });

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