miniGraph.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {LocationFixture} from 'sentry-fixture/locationFixture';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render} from 'sentry-test/reactTestingLibrary';
  5. import * as eventRequest from 'sentry/components/charts/eventsRequest';
  6. import EventView from 'sentry/utils/discover/eventView';
  7. import MiniGraph from 'sentry/views/discover/miniGraph';
  8. jest.mock('sentry/components/charts/eventsRequest');
  9. describe('Discover > MiniGraph', function () {
  10. const features = ['discover-basic'];
  11. const location = LocationFixture({
  12. query: {query: 'tag:value'},
  13. pathname: '/',
  14. });
  15. let organization, eventView, initialData;
  16. beforeEach(() => {
  17. organization = OrganizationFixture({
  18. features,
  19. });
  20. initialData = initializeOrg({
  21. organization,
  22. router: {
  23. location,
  24. },
  25. projects: [],
  26. });
  27. eventView = EventView.fromSavedQueryOrLocation(undefined, location);
  28. MockApiClient.clearMockResponses();
  29. MockApiClient.addMockResponse({
  30. url: '/organizations/org-slug/events-stats/',
  31. statusCode: 200,
  32. });
  33. });
  34. it('makes an EventsRequest with all selected multi y axis', function () {
  35. const yAxis = ['count()', 'failure_count()'];
  36. render(
  37. <MiniGraph
  38. location={location}
  39. eventView={eventView}
  40. organization={organization}
  41. yAxis={yAxis}
  42. />,
  43. {router: initialData.router}
  44. );
  45. expect(eventRequest.default).toHaveBeenCalledWith(
  46. expect.objectContaining({yAxis}),
  47. expect.anything()
  48. );
  49. });
  50. it('uses low fidelity interval for bar charts', function () {
  51. const yAxis = ['count()', 'failure_count()'];
  52. eventView.display = 'bar';
  53. render(
  54. <MiniGraph
  55. location={location}
  56. eventView={eventView}
  57. organization={organization}
  58. yAxis={yAxis}
  59. />,
  60. {router: initialData.router}
  61. );
  62. expect(eventRequest.default).toHaveBeenCalledWith(
  63. expect.objectContaining({interval: '12h'}),
  64. expect.anything()
  65. );
  66. });
  67. });