diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-08-28 07:53:48 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-08-28 07:53:48 +0000 |
commit | ecfdbee6cf03438a2455a8d4c7290ebc947d6abb (patch) | |
tree | 9655ed34b15e8495b8f898386afd8007af05d40d /spec/javascripts | |
parent | 722631a9290e07cc0d83baf7bf332223ab7cf8b6 (diff) | |
download | gitlab-ce-ecfdbee6cf03438a2455a8d4c7290ebc947d6abb.tar.gz |
Creates vue component for environments block
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/jobs/components/environments_block_spec.js | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/spec/javascripts/jobs/components/environments_block_spec.js b/spec/javascripts/jobs/components/environments_block_spec.js new file mode 100644 index 00000000000..015c26be9fc --- /dev/null +++ b/spec/javascripts/jobs/components/environments_block_spec.js @@ -0,0 +1,137 @@ +import Vue from 'vue'; +import component from '~/jobs/components/environments_block.vue'; +import mountComponent from '../../helpers/vue_mount_component_helper'; + +describe('Environments block', () => { + const Component = Vue.extend(component); + let vm; + const icon = { + group: 'success', + icon: 'status_success', + label: 'passed', + text: 'passed', + tooltip: 'passed', + }; + const deployment = { + path: 'deployment', + name: 'deployment name', + }; + const environment = { + path: '/environment', + name: 'environment', + }; + + afterEach(() => { + vm.$destroy(); + }); + + describe('with latest deployment', () => { + it('renders info for most recent deployment', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'latest', + icon, + deployment, + environment, + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'This job is the most recent deployment to environment.', + ); + }); + }); + + describe('with out of date deployment', () => { + describe('with last deployment', () => { + it('renders info for out date and most recent', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'out_of_date', + icon, + deployment, + environment: Object.assign({}, environment, { + last_deployment: { name: 'deployment', path: 'last_deployment' }, + }), + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'This job is an out-of-date deployment to environment. View the most recent deployment deployment.', + ); + }); + }); + + describe('without last deployment', () => { + it('renders info about out of date deployment', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'out_of_date', + icon, + deployment: null, + environment, + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'This job is an out-of-date deployment to environment.', + ); + }); + }); + }); + + describe('with failed deployment', () => { + it('renders info about failed deployment', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'failed', + icon, + deployment: null, + environment, + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'The deployment of this job to environment did not succeed.', + ); + }); + }); + + describe('creating deployment', () => { + describe('with last deployment', () => { + it('renders info about creating deployment and overriding lastest deployment', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'creating', + icon, + deployment, + environment: Object.assign({}, environment, { + last_deployment: { name: 'deployment', path: 'last_deployment' }, + }), + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'This job is creating a deployment to environment and will overwrite the last deployment.', + ); + }); + }); + + describe('without last deployment', () => { + it('renders info about failed deployment', () => { + vm = mountComponent(Component, { + deploymentStatus: { + status: 'creating', + icon, + deployment: null, + environment, + }, + }); + + expect(vm.$el.textContent.trim()).toEqual( + 'This job is creating a deployment to environment.', + ); + }); + }); + }); +}); |