Commit a944977d authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'vs-migrate-review-app-link-vtu' into 'master'

Migrate review_app_link_spec to VTU

See merge request gitlab-org/gitlab!56500
parents 68e7f316 a2537e0f
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import { mockTracking, triggerEvent } from 'helpers/tracking_helper'; import { mockTracking, triggerEvent } from 'helpers/tracking_helper';
import mountComponent from 'helpers/vue_mount_component_helper'; import ReviewAppLink from '~/vue_merge_request_widget/components/review_app_link.vue';
import component from '~/vue_merge_request_widget/components/review_app_link.vue';
describe('review app link', () => { describe('review app link', () => {
const Component = Vue.extend(component);
const props = { const props = {
link: '/review', link: '/review',
cssClass: 'js-link', cssClass: 'js-link',
...@@ -13,37 +11,35 @@ describe('review app link', () => { ...@@ -13,37 +11,35 @@ describe('review app link', () => {
tooltip: '', tooltip: '',
}, },
}; };
let vm; let wrapper;
let el;
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, props); wrapper = shallowMount(ReviewAppLink, { propsData: props });
el = vm.$el;
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('renders provided link as href attribute', () => { it('renders provided link as href attribute', () => {
expect(el.getAttribute('href')).toEqual(props.link); expect(wrapper.attributes('href')).toBe(props.link);
}); });
it('renders provided cssClass as class attribute', () => { it('renders provided cssClass as class attribute', () => {
expect(el.getAttribute('class')).toContain(props.cssClass); expect(wrapper.classes('js-link')).toBe(true);
}); });
it('renders View app text', () => { it('renders View app text', () => {
expect(el.textContent.trim()).toEqual('View app'); expect(wrapper.text().trim()).toBe('View app');
}); });
it('renders svg icon', () => { it('renders svg icon', () => {
expect(el.querySelector('svg')).not.toBeNull(); expect(wrapper.find('svg')).not.toBeNull();
}); });
it('tracks an event when clicked', () => { it('tracks an event when clicked', () => {
const spy = mockTracking('_category_', el, jest.spyOn); const spy = mockTracking('_category_', wrapper.element, jest.spyOn);
triggerEvent(el); triggerEvent(wrapper.element);
expect(spy).toHaveBeenCalledWith('_category_', 'open_review_app', { expect(spy).toHaveBeenCalledWith('_category_', 'open_review_app', {
label: 'review_app', label: 'review_app',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment