2019-12-02 07:06:45 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
2020-06-23 20:08:43 -04:00
|
|
|
import pipelineTriggerer from '~/pipelines/components/pipelines_list/pipeline_triggerer.vue';
|
2019-03-14 16:38:57 -04:00
|
|
|
|
|
|
|
describe('Pipelines Triggerer', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2019-12-02 07:06:45 -05:00
|
|
|
const expectComponentWithProps = (Component, props = {}) => {
|
|
|
|
const componentWrapper = wrapper.find(Component);
|
|
|
|
expect(componentWrapper.isVisible()).toBe(true);
|
|
|
|
expect(componentWrapper.props()).toEqual(expect.objectContaining(props));
|
|
|
|
};
|
|
|
|
|
2019-03-14 16:38:57 -04:00
|
|
|
const mockData = {
|
|
|
|
pipeline: {
|
|
|
|
user: {
|
|
|
|
name: 'foo',
|
|
|
|
avatar_url: '/avatar',
|
|
|
|
path: '/path',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = () => {
|
2019-12-02 07:06:45 -05:00
|
|
|
wrapper = shallowMount(pipelineTriggerer, {
|
2019-03-14 16:38:57 -04:00
|
|
|
propsData: mockData,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a table cell', () => {
|
|
|
|
expect(wrapper.contains('.table-section')).toBe(true);
|
|
|
|
});
|
|
|
|
|
2019-12-02 07:06:45 -05:00
|
|
|
it('should pass triggerer information when triggerer is provided', () => {
|
|
|
|
expectComponentWithProps(UserAvatarLink, {
|
|
|
|
linkHref: mockData.pipeline.user.path,
|
|
|
|
tooltipText: mockData.pipeline.user.name,
|
|
|
|
imgSrc: mockData.pipeline.user.avatar_url,
|
|
|
|
});
|
2019-03-14 16:38:57 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render "API" when no triggerer is provided', () => {
|
|
|
|
wrapper.setProps({
|
|
|
|
pipeline: {
|
|
|
|
user: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-12-02 07:06:45 -05:00
|
|
|
return wrapper.vm.$nextTick(() => {
|
2019-10-31 08:06:26 -04:00
|
|
|
expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API');
|
|
|
|
});
|
2019-03-14 16:38:57 -04:00
|
|
|
});
|
|
|
|
});
|