miniGraph.spec.tsx 2.2 KB

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