import {mountWithTheme} from 'sentry-test/enzyme'; import {mountGlobalModal} from 'sentry-test/modal'; import {closeModal, openModal} from 'sentry/actionCreators/modal'; import GlobalModal from 'sentry/components/globalModal'; describe('GlobalModal', function () { it('renders', function () { const wrapper = mountWithTheme(); wrapper.unmount(); }); it('uses actionCreators to open and close Modal', async function () { const wrapper = mountWithTheme(); openModal(() => ); const modal = await mountGlobalModal(); expect(modal.text()).toBe('Hi'); wrapper.update(); expect(wrapper.find('GlobalModal').prop('visible')).toBe(true); closeModal(); await tick(); wrapper.update(); expect(wrapper.find('GlobalModal').prop('visible')).toBe(false); }); it('calls onClose handler when modal is clicked out of', async function () { const wrapper = mountWithTheme(); const closeSpy = jest.fn(); openModal( ({Header}) => ( ), {onClose: closeSpy} ); const modal = await mountGlobalModal(); modal.find('CloseButton').simulate('click'); await tick(); wrapper.update(); expect(closeSpy).toHaveBeenCalled(); }); it('calls onClose handler when closeModal prop is called', async function () { const wrapper = mountWithTheme(); const closeSpy = jest.fn(); openModal(({closeModal: cm}) =>