miniGraph.spec.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render} from 'sentry-test/reactTestingLibrary';
  4. import * as eventRequest from 'sentry/components/charts/eventsRequest';
  5. import EventView from 'sentry/utils/discover/eventView';
  6. import MiniGraph from 'sentry/views/discover/miniGraph';
  7. jest.mock('sentry/components/charts/eventsRequest');
  8. describe('Discover > MiniGraph', function () {
  9. const features = ['discover-basic'];
  10. const location = TestStubs.location({
  11. query: {query: 'tag:value'},
  12. pathname: '/',
  13. });
  14. let organization, eventView, initialData;
  15. beforeEach(() => {
  16. organization = Organization({
  17. features,
  18. projects: [TestStubs.Project()],
  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. {context: initialData.routerContext}
  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. {context: initialData.routerContext}
  61. );
  62. expect(eventRequest.default).toHaveBeenCalledWith(
  63. expect.objectContaining({interval: '12h'}),
  64. expect.anything()
  65. );
  66. });
  67. });