1234567891011121314151617181920212223242526272829303132333435363738 |
- import {act, render} from 'sentry-test/reactTestingLibrary';
- import {useSampleFields} from 'sentry/views/explore/hooks/useSampleFields';
- describe('useSampleFields', function () {
- it('allows changing sample fields', function () {
- let sampleFields, setSampleFields;
- function TestPage() {
- [sampleFields, setSampleFields] = useSampleFields();
- return null;
- }
- render(<TestPage />, {disableRouterMocks: true});
- expect(sampleFields).toEqual([
- 'span_id',
- 'project',
- 'span.op',
- 'span.description',
- 'span.duration',
- 'timestamp',
- ]); // default
- act(() => setSampleFields(['foo', 'bar']));
- expect(sampleFields).toEqual(['foo', 'bar']);
- act(() => setSampleFields([]));
- expect(sampleFields).toEqual([
- 'span_id',
- 'project',
- 'span.op',
- 'span.description',
- 'span.duration',
- 'timestamp',
- ]); // default
- });
- });
|