Commit abe86568 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'upgrade-bootstrap-vue/specs-update-pipelines' into 'master'

Prepare pipelines specs for bootstrap2

See merge request gitlab-org/gitlab!20987
parents 911bfacb fdc60ebf
...@@ -20,6 +20,7 @@ describe('pipeline graph action component', () => { ...@@ -20,6 +20,7 @@ describe('pipeline graph action component', () => {
actionIcon: 'cancel', actionIcon: 'cancel',
}, },
sync: false, sync: false,
attachToDocument: true,
}); });
}); });
......
import { mount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import pipelineTriggerer from '~/pipelines/components/pipeline_triggerer.vue'; import pipelineTriggerer from '~/pipelines/components/pipeline_triggerer.vue';
describe('Pipelines Triggerer', () => { describe('Pipelines Triggerer', () => {
let wrapper; let wrapper;
const expectComponentWithProps = (Component, props = {}) => {
const componentWrapper = wrapper.find(Component);
expect(componentWrapper.isVisible()).toBe(true);
expect(componentWrapper.props()).toEqual(expect.objectContaining(props));
};
const mockData = { const mockData = {
pipeline: { pipeline: {
user: { user: {
...@@ -15,9 +22,10 @@ describe('Pipelines Triggerer', () => { ...@@ -15,9 +22,10 @@ describe('Pipelines Triggerer', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(pipelineTriggerer, { wrapper = shallowMount(pipelineTriggerer, {
propsData: mockData, propsData: mockData,
sync: false, sync: false,
attachToDocument: true,
}); });
}; };
...@@ -33,14 +41,12 @@ describe('Pipelines Triggerer', () => { ...@@ -33,14 +41,12 @@ describe('Pipelines Triggerer', () => {
expect(wrapper.contains('.table-section')).toBe(true); expect(wrapper.contains('.table-section')).toBe(true);
}); });
it('should render triggerer information when triggerer is provided', () => { it('should pass triggerer information when triggerer is provided', () => {
const link = wrapper.find('.js-pipeline-url-user'); expectComponentWithProps(UserAvatarLink, {
linkHref: mockData.pipeline.user.path,
expect(link.attributes('href')).toEqual(mockData.pipeline.user.path); tooltipText: mockData.pipeline.user.name,
expect(link.find('.js-user-avatar-image-toolip').text()).toEqual(mockData.pipeline.user.name); imgSrc: mockData.pipeline.user.avatar_url,
expect(link.find('img.avatar').attributes('src')).toEqual( });
`${mockData.pipeline.user.avatar_url}?width=26`,
);
}); });
it('should render "API" when no triggerer is provided', () => { it('should render "API" when no triggerer is provided', () => {
...@@ -50,7 +56,7 @@ describe('Pipelines Triggerer', () => { ...@@ -50,7 +56,7 @@ describe('Pipelines Triggerer', () => {
}, },
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API'); expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API');
}); });
}); });
......
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