2017-03-20 15:36:02 +00:00
|
|
|
import Vue from 'vue';
|
2017-06-12 07:48:54 +00:00
|
|
|
import navControlsComp from '~/pipelines/components/nav_controls.vue';
|
2018-03-01 17:40:00 +00:00
|
|
|
import mountComponent from '../helpers/vue_mount_component_helper';
|
2017-03-20 15:36:02 +00:00
|
|
|
|
|
|
|
describe('Pipelines Nav Controls', () => {
|
|
|
|
let NavControlsComponent;
|
2018-03-01 17:40:00 +00:00
|
|
|
let component;
|
2017-03-20 15:36:02 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
NavControlsComponent = Vue.extend(navControlsComp);
|
|
|
|
});
|
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-03-20 15:36:02 +00:00
|
|
|
it('should render link to create a new pipeline', () => {
|
|
|
|
const mockData = {
|
|
|
|
newPipelinePath: 'foo',
|
|
|
|
ciLintPath: 'foo',
|
2017-12-21 01:30:03 +00:00
|
|
|
resetCachePath: 'foo',
|
2017-03-20 15:36:02 +00:00
|
|
|
};
|
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
component = mountComponent(NavControlsComponent, mockData);
|
2017-03-20 15:36:02 +00:00
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
expect(component.$el.querySelector('.js-run-pipeline').textContent).toContain('Run Pipeline');
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(component.$el.querySelector('.js-run-pipeline').getAttribute('href')).toEqual(
|
|
|
|
mockData.newPipelinePath,
|
|
|
|
);
|
2017-03-20 15:36:02 +00:00
|
|
|
});
|
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
it('should not render link to create pipeline if no path is provided', () => {
|
2017-03-20 15:36:02 +00:00
|
|
|
const mockData = {
|
|
|
|
helpPagePath: 'foo',
|
|
|
|
ciLintPath: 'foo',
|
2017-12-21 01:30:03 +00:00
|
|
|
resetCachePath: 'foo',
|
2017-03-20 15:36:02 +00:00
|
|
|
};
|
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
component = mountComponent(NavControlsComponent, mockData);
|
2017-03-20 15:36:02 +00:00
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
expect(component.$el.querySelector('.js-run-pipeline')).toEqual(null);
|
2017-03-20 15:36:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render link for CI lint', () => {
|
|
|
|
const mockData = {
|
|
|
|
newPipelinePath: 'foo',
|
|
|
|
helpPagePath: 'foo',
|
|
|
|
ciLintPath: 'foo',
|
2017-12-21 01:30:03 +00:00
|
|
|
resetCachePath: 'foo',
|
2017-03-20 15:36:02 +00:00
|
|
|
};
|
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
component = mountComponent(NavControlsComponent, mockData);
|
2017-03-20 15:36:02 +00:00
|
|
|
|
2018-03-01 17:40:00 +00:00
|
|
|
expect(component.$el.querySelector('.js-ci-lint').textContent.trim()).toContain('CI Lint');
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(component.$el.querySelector('.js-ci-lint').getAttribute('href')).toEqual(
|
|
|
|
mockData.ciLintPath,
|
|
|
|
);
|
2017-03-20 15:36:02 +00:00
|
|
|
});
|
2018-03-07 12:01:36 +00:00
|
|
|
|
|
|
|
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-10-17 07:13:26 +00:00
|
|
|
expect(component.$el.querySelector('.js-clear-cache').textContent.trim()).toContain(
|
|
|
|
'Clear Runner Caches',
|
|
|
|
);
|
2018-03-07 12:01:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should emit postAction event when reset runner cache button is clicked', () => {
|
2018-03-07 19:45:46 +00:00
|
|
|
spyOn(component, '$emit');
|
2018-03-07 12:01:36 +00:00
|
|
|
|
|
|
|
component.$el.querySelector('.js-clear-cache').click();
|
|
|
|
|
2018-03-07 19:45:46 +00:00
|
|
|
expect(component.$emit).toHaveBeenCalledWith('resetRunnersCache', 'foo');
|
2018-03-07 12:01:36 +00:00
|
|
|
});
|
|
|
|
});
|
2017-03-20 15:36:02 +00:00
|
|
|
});
|