mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Context start * More progress on more generic react context for services * Update * Update Page test * Fixing tests * Moving to core app
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
|
|
|
|
import { setEchoSrv } from '@grafana/runtime';
|
|
|
|
import { GrafanaContext } from '../context/GrafanaContext';
|
|
import { Echo } from '../services/echo/Echo';
|
|
|
|
import { GrafanaRoute } from './GrafanaRoute';
|
|
|
|
describe('GrafanaRoute', () => {
|
|
beforeEach(() => {
|
|
setEchoSrv(new Echo());
|
|
});
|
|
|
|
it('Parses search', () => {
|
|
let capturedProps: any;
|
|
const PageComponent = (props: any) => {
|
|
capturedProps = props;
|
|
return <div />;
|
|
};
|
|
|
|
const location = { search: '?query=hello&test=asd' } as any;
|
|
const history = {} as any;
|
|
const match = {} as any;
|
|
|
|
render(
|
|
<GrafanaContext.Provider value={getGrafanaContextMock()}>
|
|
<GrafanaRoute location={location} history={history} match={match} route={{ component: PageComponent } as any} />
|
|
</GrafanaContext.Provider>
|
|
);
|
|
|
|
expect(capturedProps.queryParams.query).toBe('hello');
|
|
});
|
|
});
|