emailVerificationModal.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import EmailVerificationModal from 'sentry/components/modals/emailVerificationModal';
  3. describe('Email Verification Modal', function () {
  4. it('renders', function () {
  5. MockApiClient.addMockResponse({
  6. url: '/users/me/emails/',
  7. body: [],
  8. });
  9. render(
  10. <EmailVerificationModal
  11. Body={(p => p.children) as any}
  12. Header={(p => p.children) as any}
  13. />
  14. );
  15. const message = screen.getByText(
  16. 'Please verify your email before taking this action',
  17. {exact: false}
  18. );
  19. expect(message.parentElement).toHaveTextContent(
  20. 'Please verify your email before taking this action, or go to your email settings.'
  21. );
  22. expect(screen.getByTestId('email-settings-link')).toHaveAttribute(
  23. 'href',
  24. '/settings/account/emails/'
  25. );
  26. expect(screen.getByText('Email Addresses')).toBeInTheDocument();
  27. });
  28. it('renders with action param', function () {
  29. const actionMessage = 'accepting the tenet';
  30. MockApiClient.addMockResponse({
  31. url: '/users/me/emails/',
  32. body: [],
  33. });
  34. render(
  35. <EmailVerificationModal
  36. Body={(p => p.children) as any}
  37. Header={(p => p.children) as any}
  38. actionMessage={actionMessage}
  39. />
  40. );
  41. const message = screen.getByText(
  42. 'Please verify your email before accepting the tenet',
  43. {exact: false}
  44. );
  45. expect(message.parentElement).toHaveTextContent(
  46. `Please verify your email before ${actionMessage}, or go to your email settings.`
  47. );
  48. });
  49. });