modal.jsx 588 B

123456789101112131415161718192021222324252627
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import GlobalModal from 'sentry/components/globalModal';
  3. const mountedModals = [];
  4. /**
  5. * @deprecated only use this with enzyme (still used in getsentry)
  6. */
  7. export async function mountGlobalModal(context) {
  8. const modal = mountWithTheme(<GlobalModal />, context);
  9. mountedModals.push(modal);
  10. await tick();
  11. modal.update();
  12. return modal;
  13. }
  14. afterEach(() => {
  15. while (mountedModals.length) {
  16. const modal = mountedModals.pop();
  17. if (modal.exists()) {
  18. // modal is still mounted
  19. modal.unmount();
  20. }
  21. }
  22. });