diff options
Diffstat (limited to 'spec/javascripts/environments')
3 files changed, 14 insertions, 157 deletions
diff --git a/spec/javascripts/environments/confirm_rollback_modal_spec.js b/spec/javascripts/environments/confirm_rollback_modal_spec.js deleted file mode 100644 index 05715bce38f..00000000000 --- a/spec/javascripts/environments/confirm_rollback_modal_spec.js +++ /dev/null @@ -1,70 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import { GlModal } from '@gitlab/ui'; -import ConfirmRollbackModal from '~/environments/components/confirm_rollback_modal.vue'; -import eventHub from '~/environments/event_hub'; - -describe('Confirm Rollback Modal Component', () => { - let environment; - - beforeEach(() => { - environment = { - name: 'test', - last_deployment: { - commit: { - short_id: 'abc0123', - }, - }, - modalId: 'test', - }; - }); - - it('should show "Rollback" when isLastDeployment is false', () => { - const component = shallowMount(ConfirmRollbackModal, { - propsData: { - environment: { - ...environment, - isLastDeployment: false, - }, - }, - }); - const modal = component.find(GlModal); - - expect(modal.attributes('title')).toContain('Rollback'); - expect(modal.attributes('title')).toContain('test'); - expect(modal.attributes('ok-title')).toBe('Rollback'); - expect(modal.text()).toContain('commit abc0123'); - expect(modal.text()).toContain('Are you sure you want to continue?'); - }); - - it('should show "Re-deploy" when isLastDeployment is true', () => { - const component = shallowMount(ConfirmRollbackModal, { - propsData: { - environment: { - ...environment, - isLastDeployment: true, - }, - }, - }); - const modal = component.find(GlModal); - - expect(modal.attributes('title')).toContain('Re-deploy'); - expect(modal.attributes('title')).toContain('test'); - expect(modal.attributes('ok-title')).toBe('Re-deploy'); - expect(modal.text()).toContain('commit abc0123'); - expect(modal.text()).toContain('Are you sure you want to continue?'); - }); - - it('should emit the "rollback" event when "ok" is clicked', () => { - environment = { ...environment, isLastDeployment: true }; - const component = shallowMount(ConfirmRollbackModal, { - propsData: { - environment, - }, - }); - const eventHubSpy = spyOn(eventHub, '$emit'); - const modal = component.find(GlModal); - modal.vm.$emit('ok'); - - expect(eventHubSpy).toHaveBeenCalledWith('rollbackEnvironment', environment); - }); -}); diff --git a/spec/javascripts/environments/environment_rollback_spec.js b/spec/javascripts/environments/environment_rollback_spec.js deleted file mode 100644 index 8c47f6a12c0..00000000000 --- a/spec/javascripts/environments/environment_rollback_spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import Vue from 'vue'; -import { shallowMount } from '@vue/test-utils'; -import { GlButton } from '@gitlab/ui'; -import eventHub from '~/environments/event_hub'; -import rollbackComp from '~/environments/components/environment_rollback.vue'; - -describe('Rollback Component', () => { - const retryUrl = 'https://gitlab.com/retry'; - let RollbackComponent; - - beforeEach(() => { - RollbackComponent = Vue.extend(rollbackComp); - }); - - it('Should render Re-deploy label when isLastDeployment is true', () => { - const component = new RollbackComponent({ - el: document.querySelector('.test-dom-element'), - propsData: { - retryUrl, - isLastDeployment: true, - environment: {}, - }, - }).$mount(); - - expect(component.$el).toHaveSpriteIcon('repeat'); - }); - - it('Should render Rollback label when isLastDeployment is false', () => { - const component = new RollbackComponent({ - el: document.querySelector('.test-dom-element'), - propsData: { - retryUrl, - isLastDeployment: false, - environment: {}, - }, - }).$mount(); - - expect(component.$el).toHaveSpriteIcon('redo'); - }); - - it('should emit a "rollback" event on button click', () => { - const eventHubSpy = spyOn(eventHub, '$emit'); - const component = shallowMount(RollbackComponent, { - propsData: { - retryUrl, - environment: { - name: 'test', - }, - }, - }); - const button = component.find(GlButton); - - button.vm.$emit('click'); - - expect(eventHubSpy).toHaveBeenCalledWith('requestRollbackEnvironment', { - retryUrl, - isLastDeployment: true, - name: 'test', - }); - }); -}); diff --git a/spec/javascripts/environments/environment_terminal_button_spec.js b/spec/javascripts/environments/environment_terminal_button_spec.js index 56e18db59c5..fc98e656efe 100644 --- a/spec/javascripts/environments/environment_terminal_button_spec.js +++ b/spec/javascripts/environments/environment_terminal_button_spec.js @@ -12,36 +12,24 @@ describe('Stop Component', () => { }).$mount(); }; - describe('enabled', () => { - beforeEach(() => { - mountWithProps({ terminalPath }); - }); - - describe('computed', () => { - it('title', () => { - expect(component.title).toEqual('Terminal'); - }); - }); - - it('should render a link to open a web terminal with the provided path', () => { - expect(component.$el.tagName).toEqual('A'); - expect(component.$el.getAttribute('data-original-title')).toEqual('Terminal'); - expect(component.$el.getAttribute('aria-label')).toEqual('Terminal'); - expect(component.$el.getAttribute('href')).toEqual(terminalPath); - }); + beforeEach(() => { + mountWithProps({ terminalPath }); + }); - it('should render a non-disabled button', () => { - expect(component.$el.classList).not.toContain('disabled'); + describe('computed', () => { + it('title', () => { + expect(component.title).toEqual('Terminal'); }); }); - describe('disabled', () => { - beforeEach(() => { - mountWithProps({ terminalPath, disabled: true }); - }); + it('should render a link to open a web terminal with the provided path', () => { + expect(component.$el.tagName).toEqual('A'); + expect(component.$el.getAttribute('data-original-title')).toEqual('Terminal'); + expect(component.$el.getAttribute('aria-label')).toEqual('Terminal'); + expect(component.$el.getAttribute('href')).toEqual(terminalPath); + }); - it('should render a disabled button', () => { - expect(component.$el.classList).toContain('disabled'); - }); + it('should render a non-disabled button', () => { + expect(component.$el.classList).not.toContain('disabled'); }); }); |
