setupAlertIntegrationButton.spec.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import SetupAlertIntegrationButton from 'sentry/views/alerts/rules/issue/setupAlertIntegrationButton';
  3. describe('SetupAlertIntegrationButton', function () {
  4. const organization = TestStubs.Organization();
  5. const project = TestStubs.Project();
  6. it('renders button if no alert integrations', function () {
  7. MockApiClient.addMockResponse({
  8. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  9. body: {
  10. ...project,
  11. hasAlertIntegrationInstalled: false,
  12. },
  13. });
  14. const {container} = render(
  15. <SetupAlertIntegrationButton
  16. projectSlug={project.slug}
  17. organization={organization}
  18. />
  19. );
  20. expect(container).toHaveTextContent('Set Up Slack Now');
  21. });
  22. it('does not renders button if alert integration installed', function () {
  23. MockApiClient.addMockResponse({
  24. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  25. body: {
  26. ...project,
  27. hasAlertIntegrationInstalled: true,
  28. },
  29. });
  30. const {container} = render(
  31. <SetupAlertIntegrationButton
  32. projectSlug={project.slug}
  33. organization={organization}
  34. />
  35. );
  36. expect(container).not.toHaveTextContent('Set Up Slack Now');
  37. });
  38. });