1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import NavControls from '~/pipelines/components/pipelines_list/nav_controls.vue';
describe('Pipelines Nav Controls', () => {
let wrapper;
const createComponent = (props) => {
wrapper = shallowMountExtended(NavControls, {
propsData: {
...props,
},
});
};
const findRunPipelineButton = () => wrapper.findByTestId('run-pipeline-button');
const findCiLintButton = () => wrapper.findByTestId('ci-lint-button');
const findClearCacheButton = () => wrapper.findByTestId('clear-cache-button');
it('should render link to create a new pipeline', () => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
createComponent(mockData);
const runPipelineButton = findRunPipelineButton();
expect(runPipelineButton.text()).toContain('Run pipeline');
expect(runPipelineButton.attributes('href')).toBe(mockData.newPipelinePath);
});
it('should not render link to create pipeline if no path is provided', () => {
const mockData = {
helpPagePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
createComponent(mockData);
expect(findRunPipelineButton().exists()).toBe(false);
});
it('should render link for CI lint', () => {
const mockData = {
newPipelinePath: 'foo',
helpPagePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
createComponent(mockData);
const ciLintButton = findCiLintButton();
expect(ciLintButton.text()).toContain('CI lint');
expect(ciLintButton.attributes('href')).toBe(mockData.ciLintPath);
});
describe('Reset Runners Cache', () => {
beforeEach(() => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
createComponent(mockData);
});
it('should render button for resetting runner caches', () => {
expect(findClearCacheButton().text()).toContain('Clear runner caches');
});
it('should emit postAction event when reset runner cache button is clicked', () => {
findClearCacheButton().vm.$emit('click');
expect(wrapper.emitted('resetRunnersCache')).toEqual([['foo']]);
});
});
});
|