2021-01-29 00:20:46 +05:30
|
|
|
import { GlButton } from '@gitlab/ui';
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import DeleteComponent from '~/environments/components/environment_delete.vue';
|
|
|
|
import eventHub from '~/environments/event_hub';
|
|
|
|
|
|
|
|
describe('External URL Component', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createWrapper = () => {
|
|
|
|
wrapper = shallowMount(DeleteComponent, {
|
|
|
|
propsData: {
|
|
|
|
environment: {},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
const findButton = () => wrapper.find(GlButton);
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(window, 'confirm');
|
|
|
|
|
|
|
|
createWrapper();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a button to delete the environment', () => {
|
|
|
|
expect(findButton().exists()).toBe(true);
|
|
|
|
expect(wrapper.attributes('title')).toEqual('Delete environment');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits requestDeleteEnvironment in the event hub when button is clicked', () => {
|
|
|
|
jest.spyOn(eventHub, '$emit');
|
|
|
|
findButton().vm.$emit('click');
|
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('requestDeleteEnvironment', wrapper.vm.environment);
|
|
|
|
});
|
|
|
|
});
|