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