emailVerificationModal.spec.tsx 1.6 KB

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