modal.jsx 513 B

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