usePageParams.spec.tsx 1004 B

1234567891011121314151617181920212223242526272829303132
  1. import {renderHook} from 'sentry-test/reactTestingLibrary';
  2. import {usePageParams} from 'sentry/views/traces/hooks/usePageParams';
  3. describe('usePageParams', function () {
  4. it('decodes no queries on page', function () {
  5. const location = {query: {}};
  6. const {result} = renderHook(() => usePageParams(location), {
  7. initialProps: {location},
  8. });
  9. expect(result.current.queries).toEqual([]);
  10. });
  11. it('decodes single query on page', function () {
  12. const location = {query: {query: 'query1'}};
  13. const {result} = renderHook(() => usePageParams(location), {
  14. initialProps: {location},
  15. });
  16. expect(result.current.queries).toEqual(['query1']);
  17. });
  18. it('decodes multiple queries on page', function () {
  19. const location = {query: {query: ['query1', 'query2', 'query3']}};
  20. const {result} = renderHook(() => usePageParams(location), {
  21. initialProps: {location},
  22. });
  23. expect(result.current.queries).toEqual(['query1', 'query2', 'query3']);
  24. });
  25. });