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

65 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import '~/commons';
2021-04-17 20:07:23 +05:30
import { mount } from '@vue/test-utils';
2021-02-22 17:27:13 +05:30
import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue';
2021-09-30 23:02:18 +05:30
import PipelinesCiTemplates from '~/pipelines/components/pipelines_list/pipelines_ci_templates.vue';
2017-08-17 22:00:37 +05:30
describe('Pipelines Empty State', () => {
2021-02-22 17:27:13 +05:30
let wrapper;
2021-04-17 20:07:23 +05:30
const findIllustration = () => wrapper.find('img');
const findButton = () => wrapper.find('a');
2021-09-30 23:02:18 +05:30
const pipelinesCiTemplates = () => wrapper.findComponent(PipelinesCiTemplates);
2021-04-17 20:07:23 +05:30
const createWrapper = (props = {}) => {
wrapper = mount(EmptyState, {
2021-09-30 23:02:18 +05:30
provide: {
pipelineEditorPath: '',
suggestedCiTemplates: [],
},
2021-02-22 17:27:13 +05:30
propsData: {
2021-04-17 20:07:23 +05:30
emptyStateSvgPath: 'foo.svg',
2021-02-22 17:27:13 +05:30
canSetCi: true,
2021-04-17 20:07:23 +05:30
...props,
2021-02-22 17:27:13 +05:30
},
});
};
2017-08-17 22:00:37 +05:30
2021-04-17 20:07:23 +05:30
describe('when user can configure CI', () => {
2021-02-22 17:27:13 +05:30
beforeEach(() => {
2021-04-17 20:07:23 +05:30
createWrapper({}, mount);
2021-02-22 17:27:13 +05:30
});
2017-08-17 22:00:37 +05:30
2021-02-22 17:27:13 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
2018-03-27 19:54:05 +05:30
});
2021-09-30 23:02:18 +05:30
it('should render the CI/CD templates', () => {
expect(pipelinesCiTemplates()).toExist();
2021-04-17 20:07:23 +05:30
});
});
describe('when user cannot configure CI', () => {
beforeEach(() => {
createWrapper({ canSetCi: false }, mount);
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('should render empty state SVG', () => {
expect(findIllustration().attributes('src')).toBe('foo.svg');
});
it('should render empty state header', () => {
expect(wrapper.text()).toBe('This project is not currently set up to run pipelines.');
});
it('should not render a link', () => {
expect(findButton().exists()).toBe(false);
2021-02-22 17:27:13 +05:30
});
2017-08-17 22:00:37 +05:30
});
});