2021-04-17 20:07:23 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-06-23 00:09:42 +05:30
|
|
|
import { mockTracking, triggerEvent } from 'helpers/tracking_helper';
|
2021-04-17 20:07:23 +05:30
|
|
|
import ReviewAppLink from '~/vue_merge_request_widget/components/review_app_link.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
describe('review app link', () => {
|
|
|
|
const props = {
|
|
|
|
link: '/review',
|
|
|
|
cssClass: 'js-link',
|
2020-03-13 15:44:24 +05:30
|
|
|
display: {
|
|
|
|
text: 'View app',
|
|
|
|
tooltip: '',
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
};
|
2021-04-17 20:07:23 +05:30
|
|
|
let wrapper;
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-04-17 20:07:23 +05:30
|
|
|
wrapper = shallowMount(ReviewAppLink, { propsData: props });
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2021-04-17 20:07:23 +05:30
|
|
|
wrapper.destroy();
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided link as href attribute', () => {
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(wrapper.attributes('href')).toBe(props.link);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided cssClass as class attribute', () => {
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(wrapper.classes('js-link')).toBe(true);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders View app text', () => {
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(wrapper.text().trim()).toBe('View app');
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders svg icon', () => {
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(wrapper.find('svg')).not.toBeNull();
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
it('tracks an event when clicked', () => {
|
2021-04-17 20:07:23 +05:30
|
|
|
const spy = mockTracking('_category_', wrapper.element, jest.spyOn);
|
|
|
|
triggerEvent(wrapper.element);
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
expect(spy).toHaveBeenCalledWith('_category_', 'open_review_app', {
|
|
|
|
label: 'review_app',
|
|
|
|
});
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|