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