miniGraph.spec.tsx 2.0 KB

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