12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import {Fragment} from 'react';
- import {mountWithTheme} from 'sentry-test/enzyme';
- import {Client} from 'sentry/api';
- import TraceLiteQuery from 'sentry/utils/performance/quickTrace/traceLiteQuery';
- const traceId = 'abcdef1234567890';
- const eventId = '0987654321fedcba';
- function renderTraceLite({isLoading, error, trace, type}) {
- if (isLoading) {
- return 'loading';
- }
- if (error !== null) {
- return error;
- }
- return (
- <Fragment>
- <div key="type" data-test-id="type">
- {type}
- </div>
- <div key="trace" data-test-id="trace">
- {trace.length}
- </div>
- </Fragment>
- );
- }
- describe('TraceLiteQuery', function () {
- let api, location;
- beforeEach(function () {
- api = new Client();
- location = {
- pathname: '/',
- query: {},
- };
- });
- it('fetches data on mount and passes the event id', async function () {
- const getMock = MockApiClient.addMockResponse({
- url: `/organizations/test-org/events-trace-light/${traceId}/`,
- body: [],
- match: [MockApiClient.matchQuery({event_id: eventId})],
- });
- const wrapper = mountWithTheme(
- <TraceLiteQuery
- api={api}
- traceId={traceId}
- eventId={eventId}
- location={location}
- orgSlug="test-org"
- statsPeriod="24h"
- >
- {renderTraceLite}
- </TraceLiteQuery>
- );
- await tick();
- wrapper.update();
- expect(getMock).toHaveBeenCalledTimes(1);
- expect(wrapper.find('div[data-test-id="type"]').text()).toEqual('partial');
- });
- });
|