useSampleFields.spec.tsx 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {act, render} from 'sentry-test/reactTestingLibrary';
  2. import {useSampleFields} from 'sentry/views/explore/hooks/useSampleFields';
  3. describe('useSampleFields', function () {
  4. it('allows changing sample fields', function () {
  5. let sampleFields, setSampleFields;
  6. function TestPage() {
  7. [sampleFields, setSampleFields] = useSampleFields();
  8. return null;
  9. }
  10. render(<TestPage />, {disableRouterMocks: true});
  11. expect(sampleFields).toEqual([
  12. 'id',
  13. 'project',
  14. 'span.op',
  15. 'span.description',
  16. 'span.duration',
  17. 'timestamp',
  18. ]); // default
  19. act(() => setSampleFields(['foo', 'bar']));
  20. expect(sampleFields).toEqual(['foo', 'bar']);
  21. act(() => setSampleFields([]));
  22. expect(sampleFields).toEqual([
  23. 'id',
  24. 'project',
  25. 'span.op',
  26. 'span.description',
  27. 'span.duration',
  28. 'timestamp',
  29. ]); // default
  30. });
  31. });