2021-10-04 14:12:46 -04:00
|
|
|
import { GlDropdownItem } from '@gitlab/ui';
|
2020-10-20 23:08:45 -04:00
|
|
|
|
2020-03-25 05:08:11 -04:00
|
|
|
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-10-04 14:12:46 -04:00
|
|
|
const findDropdownItem = () => wrapper.find(GlDropdownItem);
|
2020-03-25 05:08:11 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(window, 'confirm');
|
|
|
|
|
|
|
|
createWrapper();
|
|
|
|
});
|
|
|
|
|
2021-10-04 14:12:46 -04:00
|
|
|
it('should render a dropdown item to delete the environment', () => {
|
|
|
|
expect(findDropdownItem().exists()).toBe(true);
|
|
|
|
expect(wrapper.text()).toEqual('Delete environment');
|
|
|
|
expect(findDropdownItem().attributes('variant')).toBe('danger');
|
2020-03-25 05:08:11 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('emits requestDeleteEnvironment in the event hub when button is clicked', () => {
|
|
|
|
jest.spyOn(eventHub, '$emit');
|
2021-10-04 14:12:46 -04:00
|
|
|
findDropdownItem().vm.$emit('click');
|
2020-03-25 05:08:11 -04:00
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('requestDeleteEnvironment', wrapper.vm.environment);
|
|
|
|
});
|
|
|
|
});
|