errorRobot.spec.jsx 2.0 KB

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