errorRobot.spec.jsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {Client} from 'app/api';
  3. import {ErrorRobot} from 'app/components/errorRobot';
  4. describe('ErrorRobot', function () {
  5. let getIssues;
  6. beforeEach(function () {
  7. Client.clearMockResponses();
  8. getIssues = Client.addMockResponse({
  9. url: '/projects/org-slug/project-slug/issues/',
  10. method: 'GET',
  11. body: [],
  12. });
  13. });
  14. describe('with a project', function () {
  15. let wrapper;
  16. beforeEach(function () {
  17. wrapper = mountWithTheme(
  18. <ErrorRobot
  19. api={new MockApiClient()}
  20. org={TestStubs.Organization()}
  21. project={TestStubs.Project()}
  22. />,
  23. TestStubs.routerContext()
  24. );
  25. });
  26. it('Renders a button for creating an event', function () {
  27. const button = wrapper.find('Button[data-test-id="create-sample-event"]');
  28. expect(button.exists).toBeTruthy();
  29. expect(button.props().disabled).toBeFalsy();
  30. expect(getIssues).toHaveBeenCalled();
  31. });
  32. it('Renders installation instructions', function () {
  33. const button = wrapper.find('Button[priority="primary"]');
  34. expect(button).toHaveLength(1);
  35. expect(button.props().to).toEqual(expect.stringContaining('getting-started'));
  36. });
  37. });
  38. describe('without a project', function () {
  39. let wrapper;
  40. beforeEach(function () {
  41. wrapper = mountWithTheme(
  42. <ErrorRobot api={new MockApiClient()} org={TestStubs.Organization()} />,
  43. TestStubs.routerContext()
  44. );
  45. });
  46. it('Renders a disabled create event button', function () {
  47. const button = wrapper.find('Button[data-test-id="create-sample-event"]');
  48. expect(button.exists).toBeTruthy();
  49. expect(button.props().disabled).toBeTruthy();
  50. expect(getIssues).toHaveBeenCalledTimes(0);
  51. });
  52. it('does not display install instructions', function () {
  53. const button = wrapper.find('Button[priority="primary"]');
  54. expect(button).toHaveLength(0);
  55. });
  56. });
  57. });