debian-mirror-gitlab/spec/frontend/pipelines/pipeline_triggerer_spec.js

62 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { shallowMount } from '@vue/test-utils';
2020-07-28 23:09:34 +05:30
import pipelineTriggerer from '~/pipelines/components/pipelines_list/pipeline_triggerer.vue';
2021-03-11 19:13:27 +05:30
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
2019-07-31 22:56:46 +05:30
describe('Pipelines Triggerer', () => {
let wrapper;
2020-01-01 13:55:28 +05:30
const expectComponentWithProps = (Component, props = {}) => {
const componentWrapper = wrapper.find(Component);
expect(componentWrapper.isVisible()).toBe(true);
expect(componentWrapper.props()).toEqual(expect.objectContaining(props));
};
2019-07-31 22:56:46 +05:30
const mockData = {
pipeline: {
user: {
name: 'foo',
avatar_url: '/avatar',
path: '/path',
},
},
};
const createComponent = () => {
2020-01-01 13:55:28 +05:30
wrapper = shallowMount(pipelineTriggerer, {
2019-07-31 22:56:46 +05:30
propsData: mockData,
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('should render a table cell', () => {
2020-11-24 15:15:51 +05:30
expect(wrapper.find('.table-section').exists()).toBe(true);
2019-07-31 22:56:46 +05:30
});
2020-01-01 13:55:28 +05:30
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-07-31 22:56:46 +05:30
});
it('should render "API" when no triggerer is provided', () => {
wrapper.setProps({
pipeline: {
user: null,
},
});
2020-01-01 13:55:28 +05:30
return wrapper.vm.$nextTick(() => {
2019-12-26 22:10:19 +05:30
expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API');
});
2019-07-31 22:56:46 +05:30
});
});