eventsAreaChart.spec.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {mockZoomRange} from 'sentry-test/charts';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import BaseChart from 'sentry/components/charts/baseChart';
  5. import EventsChart from 'sentry/components/charts/eventsChart';
  6. jest.mock('sentry/components/charts/baseChart', () => {
  7. return jest.fn().mockImplementation(() => <div data-test-id="area-chart" />);
  8. });
  9. describe('EventsChart with legend', function () {
  10. const {router, org} = initializeOrg();
  11. beforeEach(function () {
  12. mockZoomRange(1543449600000, 1543708800000);
  13. MockApiClient.addMockResponse({
  14. url: `/organizations/${org.slug}/releases/`,
  15. body: [],
  16. });
  17. MockApiClient.addMockResponse({
  18. url: `/organizations/${org.slug}/releases/stats/`,
  19. body: [],
  20. });
  21. MockApiClient.addMockResponse({
  22. url: `/organizations/${org.slug}/events-stats/`,
  23. method: 'GET',
  24. body: {
  25. data: [
  26. [1543449600, [20, 12]],
  27. [1543449601, [10, 5]],
  28. ],
  29. },
  30. });
  31. });
  32. it('renders a legend if enabled', async function () {
  33. render(
  34. <EventsChart
  35. api={new MockApiClient()}
  36. location={{query: {}}}
  37. organization={org}
  38. project={[]}
  39. environment={[]}
  40. period="14d"
  41. start={null}
  42. end={null}
  43. utc={false}
  44. router={router}
  45. showLegend
  46. />
  47. );
  48. expect(await screen.findByTestId('area-chart')).toBeInTheDocument();
  49. expect(BaseChart.mock.calls[0][0].legend).toHaveProperty('data');
  50. });
  51. });