mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Navigation: share logic between buildBreadcrumbs and usePageTitle (#58819)
* simplify usePageTitle logic a bit * use buildBreadcrumbs logic in usePageTitle * always add home item to navTree, fix some tests * fix remaining unit tests
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
|
||||
|
||||
import { backendSrv } from '../../core/services/backend_srv';
|
||||
import { configureStore } from '../../store/configureStore';
|
||||
|
||||
import { SignupInvitedPage, Props } from './SignupInvited';
|
||||
|
||||
@@ -28,6 +30,7 @@ const defaultGet = {
|
||||
|
||||
async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet | null } = {}) {
|
||||
jest.clearAllMocks();
|
||||
const store = configureStore();
|
||||
|
||||
const getSpy = jest.spyOn(backendSrv, 'get');
|
||||
getSpy.mockResolvedValue(get);
|
||||
@@ -43,7 +46,11 @@ async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet
|
||||
}),
|
||||
};
|
||||
|
||||
render(<SignupInvitedPage {...props} />);
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<SignupInvitedPage {...props} />
|
||||
</Provider>
|
||||
);
|
||||
|
||||
await waitFor(() => expect(getSpy).toHaveBeenCalled());
|
||||
expect(getSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
Reference in New Issue
Block a user