emailVerificationModal.spec.tsx 1.7 KB

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