summaryrefslogtreecommitdiff
path: root/spec/frontend/issue_show/components/pinned_links_spec.js
blob: 2d140fd068a4607f744314a11f097b6988f8fc82 (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
import { shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import PinnedLinks from '~/issue_show/components/pinned_links.vue';
import { STATUS_PAGE_PUBLISHED, JOIN_ZOOM_MEETING } from '~/issue_show/constants';

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

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

  const findButtons = () => wrapper.findAll(GlButton);

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

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

    expect(findButtons().at(0).text()).toBe(JOIN_ZOOM_MEETING);
  });

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

    expect(findButtons().at(0).text()).toBe(STATUS_PAGE_PUBLISHED);
  });

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

    expect(findButtons()).toHaveLength(0);
  });
});