affectOtherProjectsTransactionsAlert.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {getMockData} from '../testUtils';
  3. import {AffectOtherProjectsTransactionsAlert} from './affectOtherProjectsTransactionsAlert';
  4. describe("Affect other project's transactions alert", function () {
  5. it('does not render', function () {
  6. const {project} = getMockData();
  7. const {rerender} = render(
  8. <AffectOtherProjectsTransactionsAlert
  9. isProjectIncompatible
  10. projectSlug={project.slug}
  11. affectedProjects={[project]}
  12. />
  13. );
  14. expect(screen.queryByText(/This rate will affect/)).not.toBeInTheDocument(); // project is incompatible
  15. rerender(
  16. <AffectOtherProjectsTransactionsAlert
  17. isProjectIncompatible={false}
  18. projectSlug={project.slug}
  19. affectedProjects={[project]}
  20. />
  21. );
  22. expect(screen.queryByText(/This rate will affect/)).not.toBeInTheDocument(); // there is only one affected project and it is the current project
  23. rerender(
  24. <AffectOtherProjectsTransactionsAlert
  25. isProjectIncompatible={false}
  26. projectSlug={project.slug}
  27. affectedProjects={[]}
  28. />
  29. );
  30. expect(screen.queryByText(/This rate will affect/)).not.toBeInTheDocument(); // there is no affected project
  31. });
  32. it('renders', function () {
  33. const {projects} = getMockData();
  34. render(
  35. <AffectOtherProjectsTransactionsAlert
  36. isProjectIncompatible={false}
  37. projectSlug="some-project-slug"
  38. affectedProjects={projects}
  39. />
  40. );
  41. expect(screen.getByText(/This rate will affect/)).toBeInTheDocument();
  42. });
  43. });