pinned_links_spec.js 970 字节
Newer Older
1
import { shallowMount } from '@vue/test-utils';
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import { GlLink } from '@gitlab/ui';
import PinnedLinks from '~/issue_show/components/pinned_links.vue';

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

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

  const link = {
    get text() {
      return wrapper.find(GlLink).text();
    },
    get href() {
      return wrapper.find(GlLink).attributes('href');
    },
  };

  const createComponent = props => {
20
    wrapper = shallowMount(PinnedLinks, {
21 22
      sync: false,
      propsData: {
23
        zoomMeetingUrl: null,
24 25 26 27 28 29 30
        ...props,
      },
    });
  };

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

    expect(link.text).toBe('Join Zoom meeting');
  });

37
  it('does not render if there are no links', () => {
38
    createComponent({
39
      zoomMeetingUrl: null,
40 41 42 43 44
    });

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