import {Fragment} from 'react'; import {render, screen} from 'sentry-test/reactTestingLibrary'; import {Client} from 'sentry/api'; import EventView from 'sentry/utils/discover/eventView'; import HistogramQuery from 'sentry/utils/performance/histogram/histogramQuery'; function renderHistogram({isLoading, error, histograms}) { if (isLoading) { return 'loading'; } if (error !== null) { return 'error'; } return ( {Object.keys(histograms).map(name => (

{name}

))}
); } describe('HistogramQuery', function () { let api, eventView, location; beforeEach(function () { api = new Client(); location = { pathname: '/', query: {}, }; eventView = EventView.fromSavedQuery({ id: '', name: '', version: 2, fields: ['id'], projects: [], environment: ['dev'], }); }); it('fetches data on mount', async function () { const getMock = MockApiClient.addMockResponse({ url: '/organizations/test-org/events-histogram/', body: { 'measurements.fp': Array(10) .fill(null) .map((_, i) => ({bin: i * 1000, count: i})), }, }); render( {renderHistogram} ); expect(await screen.findByText('measurements.fp')).toBeInTheDocument(); expect(screen.getAllByRole('listitem')).toHaveLength(10); expect(getMock).toHaveBeenCalledTimes(1); }); });