summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-20 15:07:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-20 15:07:34 +0000
commit8b61452138ecc511b52cd49be4ee6b8a80390c50 (patch)
tree122b817432c2a0f0e23767bd95791a89b20540c0 /spec/frontend/pipelines
parentf864f8a7aafa45b0e4c04e4312f89da4b1227c0f (diff)
downloadgitlab-ce-8b61452138ecc511b52cd49be4ee6b8a80390c50.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines')
-rw-r--r--spec/frontend/pipelines/nav_controls_spec.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/nav_controls_spec.js b/spec/frontend/pipelines/nav_controls_spec.js
new file mode 100644
index 00000000000..6d28da0ea2a
--- /dev/null
+++ b/spec/frontend/pipelines/nav_controls_spec.js
@@ -0,0 +1,85 @@
+import Vue from 'vue';
+import navControlsComp from '~/pipelines/components/nav_controls.vue';
+import mountComponent from '../helpers/vue_mount_component_helper';
+
+describe('Pipelines Nav Controls', () => {
+ let NavControlsComponent;
+ let component;
+
+ beforeEach(() => {
+ NavControlsComponent = Vue.extend(navControlsComp);
+ });
+
+ afterEach(() => {
+ component.$destroy();
+ });
+
+ it('should render link to create a new pipeline', () => {
+ const mockData = {
+ newPipelinePath: 'foo',
+ ciLintPath: 'foo',
+ resetCachePath: 'foo',
+ };
+
+ component = mountComponent(NavControlsComponent, mockData);
+
+ expect(component.$el.querySelector('.js-run-pipeline').textContent).toContain('Run Pipeline');
+ expect(component.$el.querySelector('.js-run-pipeline').getAttribute('href')).toEqual(
+ mockData.newPipelinePath,
+ );
+ });
+
+ it('should not render link to create pipeline if no path is provided', () => {
+ const mockData = {
+ helpPagePath: 'foo',
+ ciLintPath: 'foo',
+ resetCachePath: 'foo',
+ };
+
+ component = mountComponent(NavControlsComponent, mockData);
+
+ expect(component.$el.querySelector('.js-run-pipeline')).toEqual(null);
+ });
+
+ it('should render link for CI lint', () => {
+ const mockData = {
+ newPipelinePath: 'foo',
+ helpPagePath: 'foo',
+ ciLintPath: 'foo',
+ resetCachePath: 'foo',
+ };
+
+ component = mountComponent(NavControlsComponent, mockData);
+
+ expect(component.$el.querySelector('.js-ci-lint').textContent.trim()).toContain('CI Lint');
+ expect(component.$el.querySelector('.js-ci-lint').getAttribute('href')).toEqual(
+ mockData.ciLintPath,
+ );
+ });
+
+ 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', () => {
+ expect(component.$el.querySelector('.js-clear-cache').textContent.trim()).toContain(
+ 'Clear Runner Caches',
+ );
+ });
+
+ it('should emit postAction event when reset runner cache button is clicked', () => {
+ jest.spyOn(component, '$emit').mockImplementation(() => {});
+
+ component.$el.querySelector('.js-clear-cache').click();
+
+ expect(component.$emit).toHaveBeenCalledWith('resetRunnersCache', 'foo');
+ });
+ });
+});