diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 18:06:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-26 18:06:33 +0000 |
commit | 581c10e344d85729e77fce78513819d159289dc5 (patch) | |
tree | ea84e89fddcafe5a8abdc8a9a5f7f210b6644e77 /spec/frontend | |
parent | 68d3f33d5194c446812d09f079749ddf56f95378 (diff) | |
download | gitlab-ce-581c10e344d85729e77fce78513819d159289dc5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
3 files changed, 115 insertions, 0 deletions
diff --git a/spec/frontend/environments/environment_monitoring_spec.js b/spec/frontend/environments/environment_monitoring_spec.js new file mode 100644 index 00000000000..8e67f799dc0 --- /dev/null +++ b/spec/frontend/environments/environment_monitoring_spec.js @@ -0,0 +1,39 @@ +import { shallowMount } from '@vue/test-utils'; +import MonitoringComponent from '~/environments/components/environment_monitoring.vue'; +import Icon from '~/vue_shared/components/icon.vue'; + +describe('Monitoring Component', () => { + let wrapper; + + const monitoringUrl = 'https://gitlab.com'; + + const createWrapper = () => { + wrapper = shallowMount(MonitoringComponent, { + sync: false, + attachToDocument: true, + propsData: { + monitoringUrl, + }, + }); + }; + + const findIcons = () => wrapper.findAll(Icon); + const findIconsByName = name => findIcons().filter(icon => icon.props('name') === name); + + beforeEach(() => { + createWrapper(); + }); + + describe('computed', () => { + it('title', () => { + expect(wrapper.vm.title).toBe('Monitoring'); + }); + }); + + it('should render a link to environment monitoring page', () => { + expect(wrapper.attributes('href')).toEqual(monitoringUrl); + expect(findIconsByName('chart').length).toBe(1); + expect(wrapper.attributes('data-original-title')).toBe('Monitoring'); + expect(wrapper.attributes('aria-label')).toBe('Monitoring'); + }); +}); diff --git a/spec/frontend/environments/environment_stop_spec.js b/spec/frontend/environments/environment_stop_spec.js new file mode 100644 index 00000000000..ab714728311 --- /dev/null +++ b/spec/frontend/environments/environment_stop_spec.js @@ -0,0 +1,40 @@ +import $ from 'jquery'; +import { shallowMount } from '@vue/test-utils'; +import StopComponent from '~/environments/components/environment_stop.vue'; +import LoadingButton from '~/vue_shared/components/loading_button.vue'; +import eventHub from '~/environments/event_hub'; + +$.fn.tooltip = () => {}; + +describe('Stop Component', () => { + let wrapper; + + const createWrapper = () => { + wrapper = shallowMount(StopComponent, { + sync: false, + attachToDocument: true, + propsData: { + environment: {}, + }, + }); + }; + + const findButton = () => wrapper.find(LoadingButton); + + beforeEach(() => { + jest.spyOn(window, 'confirm'); + + createWrapper(); + }); + + it('should render a button to stop the environment', () => { + expect(findButton().exists()).toBe(true); + expect(wrapper.attributes('data-original-title')).toEqual('Stop environment'); + }); + + it('emits requestStopEnvironment in the event hub when button is clicked', () => { + jest.spyOn(eventHub, '$emit'); + findButton().vm.$emit('click'); + expect(eventHub.$emit).toHaveBeenCalledWith('requestStopEnvironment', wrapper.vm.environment); + }); +}); diff --git a/spec/frontend/environments/environment_terminal_button_spec.js b/spec/frontend/environments/environment_terminal_button_spec.js new file mode 100644 index 00000000000..9aa2b82736c --- /dev/null +++ b/spec/frontend/environments/environment_terminal_button_spec.js @@ -0,0 +1,36 @@ +import { shallowMount } from '@vue/test-utils'; +import TerminalComponent from '~/environments/components/environment_terminal_button.vue'; + +describe('Stop Component', () => { + let wrapper; + const terminalPath = '/path'; + + const mountWithProps = props => { + wrapper = shallowMount(TerminalComponent, { + sync: false, + attachToDocument: true, + propsData: props, + }); + }; + + beforeEach(() => { + mountWithProps({ terminalPath }); + }); + + describe('computed', () => { + it('title', () => { + expect(wrapper.vm.title).toEqual('Terminal'); + }); + }); + + it('should render a link to open a web terminal with the provided path', () => { + expect(wrapper.is('a')).toBe(true); + expect(wrapper.attributes('data-original-title')).toBe('Terminal'); + expect(wrapper.attributes('aria-label')).toBe('Terminal'); + expect(wrapper.attributes('href')).toBe(terminalPath); + }); + + it('should render a non-disabled button', () => { + expect(wrapper.classes()).not.toContain('disabled'); + }); +}); |