2020-01-08 07:07:59 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-06-19 08:09:07 -04:00
|
|
|
import { GlButton } from '@gitlab/ui';
|
2019-06-11 00:15:08 -04:00
|
|
|
import PinnedLinks from '~/issue_show/components/pinned_links.vue';
|
2020-06-19 08:09:07 -04:00
|
|
|
import { STATUS_PAGE_PUBLISHED, JOIN_ZOOM_MEETING } from '~/issue_show/constants';
|
2019-06-11 00:15:08 -04:00
|
|
|
|
|
|
|
const plainZoomUrl = 'https://zoom.us/j/123456789';
|
2020-06-11 05:08:16 -04:00
|
|
|
const plainStatusUrl = 'https://status.com';
|
2019-06-11 00:15:08 -04:00
|
|
|
|
|
|
|
describe('PinnedLinks', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2020-06-19 08:09:07 -04:00
|
|
|
const findButtons = () => wrapper.findAll(GlButton);
|
2019-06-11 00:15:08 -04:00
|
|
|
|
|
|
|
const createComponent = props => {
|
2020-01-08 07:07:59 -05:00
|
|
|
wrapper = shallowMount(PinnedLinks, {
|
2019-06-11 00:15:08 -04:00
|
|
|
propsData: {
|
2020-06-11 05:08:16 -04:00
|
|
|
zoomMeetingUrl: '',
|
|
|
|
publishedIncidentUrl: '',
|
2019-06-11 00:15:08 -04:00
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
it('displays Zoom link', () => {
|
|
|
|
createComponent({
|
2019-07-17 02:41:26 -04:00
|
|
|
zoomMeetingUrl: `<a href="${plainZoomUrl}">Zoom</a>`,
|
2019-06-11 00:15:08 -04:00
|
|
|
});
|
|
|
|
|
2020-06-11 05:08:16 -04:00
|
|
|
expect(
|
2020-06-19 08:09:07 -04:00
|
|
|
findButtons()
|
2020-06-11 05:08:16 -04:00
|
|
|
.at(0)
|
|
|
|
.text(),
|
2020-06-19 08:09:07 -04:00
|
|
|
).toBe(JOIN_ZOOM_MEETING);
|
2020-06-11 05:08:16 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('displays Status link', () => {
|
|
|
|
createComponent({
|
|
|
|
publishedIncidentUrl: `<a href="${plainStatusUrl}">Status</a>`,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
2020-06-19 08:09:07 -04:00
|
|
|
findButtons()
|
2020-06-11 05:08:16 -04:00
|
|
|
.at(0)
|
|
|
|
.text(),
|
2020-06-19 08:09:07 -04:00
|
|
|
).toBe(STATUS_PAGE_PUBLISHED);
|
2019-06-11 00:15:08 -04:00
|
|
|
});
|
|
|
|
|
2019-07-17 02:41:26 -04:00
|
|
|
it('does not render if there are no links', () => {
|
2019-06-11 00:15:08 -04:00
|
|
|
createComponent({
|
2020-06-11 05:08:16 -04:00
|
|
|
zoomMeetingUrl: '',
|
|
|
|
publishedIncidentUrl: '',
|
2019-06-11 00:15:08 -04:00
|
|
|
});
|
|
|
|
|
2020-06-19 08:09:07 -04:00
|
|
|
expect(findButtons()).toHaveLength(0);
|
2019-06-11 00:15:08 -04:00
|
|
|
});
|
|
|
|
});
|