2019-11-26 13:06:33 -05:00
|
|
|
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, {
|
|
|
|
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);
|
2019-12-20 13:07:53 -05:00
|
|
|
expect(wrapper.attributes('title')).toEqual('Stop environment');
|
2019-11-26 13:06:33 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|