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

86 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2017-09-10 17:25:29 +05:30
import navControlsComp from '~/pipelines/components/nav_controls.vue';
2018-03-27 19:54:05 +05:30
import mountComponent from '../helpers/vue_mount_component_helper';
2017-08-17 22:00:37 +05:30
describe('Pipelines Nav Controls', () => {
let NavControlsComponent;
2018-03-27 19:54:05 +05:30
let component;
2017-08-17 22:00:37 +05:30
beforeEach(() => {
NavControlsComponent = Vue.extend(navControlsComp);
});
2018-03-27 19:54:05 +05:30
afterEach(() => {
component.$destroy();
});
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
};
2018-03-27 19:54:05 +05:30
component = mountComponent(NavControlsComponent, mockData);
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
expect(component.$el.querySelector('.js-run-pipeline').textContent).toContain('Run Pipeline');
2018-12-13 13:39:08 +05:30
expect(component.$el.querySelector('.js-run-pipeline').getAttribute('href')).toEqual(
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
};
2018-03-27 19:54:05 +05:30
component = mountComponent(NavControlsComponent, mockData);
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
expect(component.$el.querySelector('.js-run-pipeline')).toEqual(null);
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
};
2018-03-27 19:54:05 +05:30
component = mountComponent(NavControlsComponent, mockData);
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
expect(component.$el.querySelector('.js-ci-lint').textContent.trim()).toContain('CI Lint');
2018-12-13 13:39:08 +05:30
expect(component.$el.querySelector('.js-ci-lint').getAttribute('href')).toEqual(
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',
};
component = mountComponent(NavControlsComponent, mockData);
});
it('should render button for resetting runner caches', () => {
2018-12-13 13:39:08 +05:30
expect(component.$el.querySelector('.js-clear-cache').textContent.trim()).toContain(
'Clear Runner Caches',
);
2018-05-09 12:01:36 +05:30
});
it('should emit postAction event when reset runner cache button is clicked', () => {
2020-03-09 13:42:32 +05:30
jest.spyOn(component, '$emit').mockImplementation(() => {});
2018-05-09 12:01:36 +05:30
component.$el.querySelector('.js-clear-cache').click();
expect(component.$emit).toHaveBeenCalledWith('resetRunnersCache', 'foo');
});
});
2017-08-17 22:00:37 +05:30
});