debian-mirror-gitlab/spec/frontend/environments/environment_delete_spec.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-11-18 22:05:49 +05:30
import { GlDropdownItem } from '@gitlab/ui';
2021-01-29 00:20:46 +05:30
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-11-18 22:05:49 +05:30
const findDropdownItem = () => wrapper.find(GlDropdownItem);
2020-04-22 19:07:51 +05:30
beforeEach(() => {
jest.spyOn(window, 'confirm');
createWrapper();
});
2021-11-18 22:05:49 +05:30
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-04-22 19:07:51 +05:30
});
it('emits requestDeleteEnvironment in the event hub when button is clicked', () => {
jest.spyOn(eventHub, '$emit');
2021-11-18 22:05:49 +05:30
findDropdownItem().vm.$emit('click');
2020-04-22 19:07:51 +05:30
expect(eventHub.$emit).toHaveBeenCalledWith('requestDeleteEnvironment', wrapper.vm.environment);
});
});