Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 16:26:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 16:26:31 +0300
commitb7dfe2ae4054aa40e15182fd3c6cb7dd39f131db (patch)
tree5ab080ca9cadeb6cd9578bf301e4e9e8810bed9e /spec/javascripts
parent25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/gl_dropdown_spec.js46
-rw-r--r--spec/javascripts/jobs/components/environments_block_spec.js78
2 files changed, 114 insertions, 10 deletions
diff --git a/spec/javascripts/gl_dropdown_spec.js b/spec/javascripts/gl_dropdown_spec.js
index 8c7820ddb52..00bc552bd7d 100644
--- a/spec/javascripts/gl_dropdown_spec.js
+++ b/spec/javascripts/gl_dropdown_spec.js
@@ -243,14 +243,23 @@ describe('glDropdown', function describeDropdown() {
});
describe('renderItem', () => {
+ function dropdownWithOptions(options) {
+ const $dropdownDiv = $('<div />');
+
+ $dropdownDiv.glDropdown(options);
+
+ return $dropdownDiv.data('glDropdown');
+ }
+
+ function basicDropdown() {
+ return dropdownWithOptions({});
+ }
+
describe('without selected value', () => {
let dropdown;
beforeEach(() => {
- const dropdownOptions = {};
- const $dropdownDiv = $('<div />');
- $dropdownDiv.glDropdown(dropdownOptions);
- dropdown = $dropdownDiv.data('glDropdown');
+ dropdown = basicDropdown();
});
it('marks items without ID as active', () => {
@@ -275,6 +284,35 @@ describe('glDropdown', function describeDropdown() {
expect(link).not.toHaveClass('is-active');
});
});
+
+ it('should return an empty .separator li when when appropriate', () => {
+ const dropdown = basicDropdown();
+ const sep = { type: 'separator' };
+ const li = dropdown.renderItem(sep);
+
+ expect(li).toHaveClass('separator');
+ expect(li.childNodes.length).toEqual(0);
+ });
+
+ it('should return an empty .divider li when when appropriate', () => {
+ const dropdown = basicDropdown();
+ const div = { type: 'divider' };
+ const li = dropdown.renderItem(div);
+
+ expect(li).toHaveClass('divider');
+ expect(li.childNodes.length).toEqual(0);
+ });
+
+ it('should return a .dropdown-header li with the correct content when when appropriate', () => {
+ const dropdown = basicDropdown();
+ const text = 'My Header';
+ const header = { type: 'header', content: text };
+ const li = dropdown.renderItem(header);
+
+ expect(li).toHaveClass('dropdown-header');
+ expect(li.childNodes.length).toEqual(1);
+ expect(li.textContent).toEqual(text);
+ });
});
it('should keep selected item after selecting a second time', () => {
diff --git a/spec/javascripts/jobs/components/environments_block_spec.js b/spec/javascripts/jobs/components/environments_block_spec.js
index 0866ddd21d8..4bbc5f5a348 100644
--- a/spec/javascripts/jobs/components/environments_block_spec.js
+++ b/spec/javascripts/jobs/components/environments_block_spec.js
@@ -18,6 +18,8 @@ describe('Environments block', () => {
name: 'environment',
};
+ const lastDeployment = { iid: 'deployment', deployable: { build_path: 'bar' } };
+
afterEach(() => {
vm.$destroy();
});
@@ -45,7 +47,7 @@ describe('Environments block', () => {
deploymentStatus: {
status: 'out_of_date',
environment: Object.assign({}, environment, {
- last_deployment: { iid: 'deployment', deployable: { build_path: 'bar' } },
+ last_deployment: lastDeployment,
}),
},
iconStatus: status,
@@ -99,10 +101,7 @@ describe('Environments block', () => {
deploymentStatus: {
status: 'creating',
environment: Object.assign({}, environment, {
- last_deployment: {
- iid: 'deployment',
- deployable: { build_path: 'foo' },
- },
+ last_deployment: lastDeployment,
}),
},
iconStatus: status,
@@ -112,7 +111,7 @@ describe('Environments block', () => {
'This job is creating a deployment to environment and will overwrite the latest deployment.',
);
- expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('foo');
+ expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('bar');
});
});
@@ -146,4 +145,71 @@ describe('Environments block', () => {
});
});
});
+
+ describe('with a cluster', () => {
+ it('renders the cluster link', () => {
+ const cluster = {
+ name: 'the-cluster',
+ path: '/the-cluster-path',
+ };
+ vm = mountComponent(Component, {
+ deploymentStatus: {
+ status: 'last',
+ environment: Object.assign({}, environment, {
+ last_deployment: {
+ ...lastDeployment,
+ cluster,
+ },
+ }),
+ },
+ iconStatus: status,
+ });
+
+ expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.');
+
+ expect(vm.$el.querySelector('.js-job-cluster-link').getAttribute('href')).toEqual(
+ '/the-cluster-path',
+ );
+ });
+
+ describe('when the cluster is missing the path', () => {
+ it('renders the name without a link', () => {
+ const cluster = {
+ name: 'the-cluster',
+ };
+ vm = mountComponent(Component, {
+ deploymentStatus: {
+ status: 'last',
+ environment: Object.assign({}, environment, {
+ last_deployment: {
+ ...lastDeployment,
+ cluster,
+ },
+ }),
+ },
+ iconStatus: status,
+ });
+
+ expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.');
+
+ expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull();
+ });
+ });
+ });
+
+ describe('without a cluster', () => {
+ it('does not render a cluster link', () => {
+ vm = mountComponent(Component, {
+ deploymentStatus: {
+ status: 'last',
+ environment: Object.assign({}, environment, {
+ last_deployment: lastDeployment,
+ }),
+ },
+ iconStatus: status,
+ });
+
+ expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull();
+ });
+ });
});