/usr/share/grafana/public/app/features/explore/hooks
import { renderHook, waitFor } from '@testing-library/react'; import { createMemoryHistory } from 'history'; import { stringify } from 'querystring'; import { TestProvider } from 'test/helpers/TestProvider'; import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { HistoryWrapper } from '@grafana/runtime'; import { useTimeSrvFix } from './useTimeSrvFix'; describe('useTimeSrvFix', () => { it('removes `from` and `to` parameters from url when first mounted', async () => { const history = createMemoryHistory({ initialEntries: [{ pathname: '/explore', search: stringify({ from: '1', to: '2' }) }], }); const location = new HistoryWrapper(history); const context = getGrafanaContextMock(); renderHook(() => useTimeSrvFix(), { wrapper: ({ children }) => ( <TestProvider grafanaContext={{ ...context, location, }} > {children} </TestProvider> ), }); await waitFor(() => { expect(location.getSearchObject()).toEqual(expect.not.objectContaining({ from: '1', to: '2' })); }); }); });
.
Edit
..
Edit
useExploreDataLinkPostProcessor.ts
Edit
useExplorePageTitle.test.tsx
Edit
useExplorePageTitle.ts
Edit
useKeyboardShortcuts.test.tsx
Edit
useKeyboardShortcuts.ts
Edit
useSplitSizeUpdater.test.tsx
Edit
useSplitSizeUpdater.ts
Edit
useStateSync
Edit
useTimeSrvFix.test.tsx
Edit
useTimeSrvFix.ts
Edit
utils.ts
Edit