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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.2 KiB
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import NavControls from '~/pipelines/components/pipelines_list/nav_controls.vue';
2017-08-17 22:00:37 +05:30
describe('Pipelines Nav Controls', () => {
2021-04-29 21:17:54 +05:30
let wrapper;
2017-08-17 22:00:37 +05:30
2021-04-29 21:17:54 +05:30
const createComponent = (props) => {
wrapper = shallowMount(NavControls, {
propsData: {
...props,
},
});
};
const findRunPipeline = () => wrapper.find('.js-run-pipeline');
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
afterEach(() => {
2021-04-29 21:17:54 +05:30
wrapper.destroy();
2018-03-27 19:54:05 +05:30
});
2017-08-17 22:00:37 +05:30
it('should render link to create a new pipeline', () => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2017-08-17 22:00:37 +05:30
2021-04-29 21:17:54 +05:30
const runPipeline = findRunPipeline();
expect(runPipeline.text()).toContain('Run pipeline');
expect(runPipeline.attributes('href')).toBe(mockData.newPipelinePath);
2017-08-17 22:00:37 +05:30
});
2018-03-27 19:54:05 +05:30
it('should not render link to create pipeline if no path is provided', () => {
2017-08-17 22:00:37 +05:30
const mockData = {
helpPagePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2017-08-17 22:00:37 +05:30
2021-04-29 21:17:54 +05:30
expect(findRunPipeline().exists()).toBe(false);
2017-08-17 22:00:37 +05:30
});
it('should render link for CI lint', () => {
const mockData = {
newPipelinePath: 'foo',
helpPagePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2017-08-17 22:00:37 +05:30
2021-04-29 21:17:54 +05:30
expect(wrapper.find('.js-ci-lint').text().trim()).toContain('CI lint');
expect(wrapper.find('.js-ci-lint').attributes('href')).toBe(mockData.ciLintPath);
2017-08-17 22:00:37 +05:30
});
2018-05-09 12:01:36 +05:30
describe('Reset Runners Cache', () => {
beforeEach(() => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2018-05-09 12:01:36 +05:30
});
it('should render button for resetting runner caches', () => {
2021-04-29 21:17:54 +05:30
expect(wrapper.find('.js-clear-cache').text().trim()).toContain('Clear runner caches');
2018-05-09 12:01:36 +05:30
});
2021-04-29 21:17:54 +05:30
it('should emit postAction event when reset runner cache button is clicked', async () => {
jest.spyOn(wrapper.vm, '$emit').mockImplementation(() => {});
2018-05-09 12:01:36 +05:30
2021-04-29 21:17:54 +05:30
wrapper.find('.js-clear-cache').vm.$emit('click');
await nextTick();
2018-05-09 12:01:36 +05:30
2021-04-29 21:17:54 +05:30
expect(wrapper.vm.$emit).toHaveBeenCalledWith('resetRunnersCache', 'foo');
2018-05-09 12:01:36 +05:30
});
});
2017-08-17 22:00:37 +05:30
});