|
| 1 | +import type {ECharts} from 'echarts'; |
1 | 2 | import {DroppedEventFixture} from 'sentry-fixture/droppedEvent'; |
2 | 3 |
|
3 | | -import {droppedEventsToSeries} from './droppedDataChart'; |
| 4 | +import {act, render} from 'sentry-test/reactTestingLibrary'; |
| 5 | + |
| 6 | +import {BaseChart} from 'sentry/components/charts/baseChart'; |
| 7 | +import type {EChartDataZoomHandler} from 'sentry/types/echarts'; |
| 8 | + |
| 9 | +import {DroppedDataChart, droppedEventsToSeries} from './droppedDataChart'; |
| 10 | + |
| 11 | +jest.mock('sentry/components/charts/baseChart', () => ({ |
| 12 | + BaseChart: jest.fn(() => null), |
| 13 | +})); |
| 14 | + |
| 15 | +describe('DroppedDataChart', () => { |
| 16 | + it('does not zoom or change the time range', () => { |
| 17 | + const {router} = render( |
| 18 | + <DroppedDataChart |
| 19 | + droppedEvents={[DroppedEventFixture({outcome: 'filtered', count: 5})]} |
| 20 | + colors={{filtered: '#000'}} |
| 21 | + selection={{}} |
| 22 | + onSelectionChange={jest.fn()} |
| 23 | + />, |
| 24 | + { |
| 25 | + initialRouterConfig: { |
| 26 | + location: {pathname: '/explore/traces/', query: {statsPeriod: '14d'}}, |
| 27 | + }, |
| 28 | + } |
| 29 | + ); |
| 30 | + |
| 31 | + const props = jest.mocked(BaseChart).mock.calls.at(-1)![0]; |
| 32 | + expect(props.toolBox).toEqual({}); |
| 33 | + |
| 34 | + act(() => { |
| 35 | + props.onDataZoom?.( |
| 36 | + { |
| 37 | + type: 'datazoom', |
| 38 | + start: 0, |
| 39 | + end: 100, |
| 40 | + batch: [{startValue: 0, endValue: 600_000}], |
| 41 | + } as Parameters<EChartDataZoomHandler>[0], |
| 42 | + {} as ECharts |
| 43 | + ); |
| 44 | + }); |
| 45 | + |
| 46 | + expect(router.location.query).toEqual({statsPeriod: '14d'}); |
| 47 | + }); |
| 48 | +}); |
4 | 49 |
|
5 | 50 | describe('droppedEventsToSeries', () => { |
6 | 51 | it('returns an empty object for no events', () => { |
|
0 commit comments