import {Fragment} from 'react'; import {mountWithTheme} from 'sentry-test/enzyme'; import {Client} from 'sentry/api'; import { TraceFullDetailedQuery, TraceFullQuery, } from 'sentry/utils/performance/quickTrace/traceFullQuery'; const traceId = 'abcdef1234567890'; const eventId = '0987654321fedcba'; function renderTraceFull({isLoading, error, type}) { if (isLoading) { return 'loading'; } if (error !== null) { return error; } return (
{type}
); } describe('TraceFullQuery', function () { let api, location; beforeEach(function () { api = new Client(); location = { pathname: '/', query: {}, }; }); it('fetches data on mount', async function () { const getMock = MockApiClient.addMockResponse({ url: `/organizations/test-org/events-trace/${traceId}/`, body: [], }); const wrapper = mountWithTheme( {renderTraceFull} ); await tick(); wrapper.update(); expect(getMock).toHaveBeenCalledTimes(1); expect(wrapper.find('div[data-test-id="type"]').text()).toEqual('full'); }); it('fetches data on mount with detailed param', async function () { const getMock = MockApiClient.addMockResponse({ url: `/organizations/test-org/events-trace/${traceId}/`, body: [], match: [MockApiClient.matchQuery({detailed: '1'})], }); const wrapper = mountWithTheme( {renderTraceFull} ); await tick(); wrapper.update(); expect(getMock).toHaveBeenCalledTimes(1); expect(wrapper.find('div[data-test-id="type"]').text()).toEqual('full'); }); });