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');
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should render link for resetting runner caches', () => {
|
|
|
|
const mockData = {
|
|
|
|
newPipelinePath: 'foo',
|
|
|
|
ciLintPath: 'foo',
|
|
|
|
resetCachePath: 'foo',
|
|
|
|
};
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
component = mountComponent(NavControlsComponent, mockData);
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
expect(component.$el.querySelector('.js-clear-cache').textContent.trim()).toContain('Clear Runner Caches');
|
|
|
|
expect(component.$el.querySelector('.js-clear-cache').getAttribute('href')).toEqual(mockData.resetCachePath);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
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');
|
|
|
|
expect(component.$el.querySelector('.js-ci-lint').getAttribute('href')).toEqual(mockData.ciLintPath);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|