GrafanaRoute.test.tsx 804 B

1234567891011121314151617181920212223242526272829303132
  1. import { render } from '@testing-library/react';
  2. import React from 'react';
  3. import { setEchoSrv } from '@grafana/runtime';
  4. import { Echo } from '../services/echo/Echo';
  5. import { GrafanaRoute } from './GrafanaRoute';
  6. describe('GrafanaRoute', () => {
  7. beforeEach(() => {
  8. setEchoSrv(new Echo());
  9. });
  10. it('Parses search', () => {
  11. let capturedProps: any;
  12. const PageComponent = (props: any) => {
  13. capturedProps = props;
  14. return <div />;
  15. };
  16. const location = { search: '?query=hello&test=asd' } as any;
  17. const history = {} as any;
  18. const match = {} as any;
  19. render(
  20. <GrafanaRoute location={location} history={history} match={match} route={{ component: PageComponent } as any} />
  21. );
  22. expect(capturedProps.queryParams.query).toBe('hello');
  23. });
  24. });