mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* hacky first attempt * slightly cleaner... * behaviour mostly working... * remove unnecessary wrapper * css tweaks * much cleaner implementation with intersectionobserver * set style props directly on children * separate story, integrate when toggle is off * improve story, integrate when toggle is on * remove styles from DashNavTimeControls * mock IntersectionObserver for all unit tests * prettier * don't use dropdown anymore * add some basic documentation * add right alignment to scenes toolbarbuttonrow * just use the react children api to prevent duplicating children
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { Router } from 'react-router-dom';
|
|
|
|
import { locationService } from '@grafana/runtime';
|
|
import { configureStore } from 'app/store/configureStore';
|
|
|
|
import TestProvider from '../../../../test/helpers/TestProvider';
|
|
|
|
import { NavBar } from './NavBar';
|
|
|
|
jest.mock('app/core/services/context_srv', () => ({
|
|
contextSrv: {
|
|
sidemenu: true,
|
|
user: {},
|
|
isSignedIn: false,
|
|
isGrafanaAdmin: false,
|
|
isEditor: false,
|
|
hasEditPermissionFolders: false,
|
|
},
|
|
}));
|
|
|
|
const setup = () => {
|
|
const store = configureStore();
|
|
|
|
return render(
|
|
<Provider store={store}>
|
|
<TestProvider>
|
|
<Router history={locationService.getHistory()}>
|
|
<NavBar />
|
|
</Router>
|
|
</TestProvider>
|
|
</Provider>
|
|
);
|
|
};
|
|
|
|
describe('Render', () => {
|
|
it('should render component', async () => {
|
|
setup();
|
|
const sidemenu = await screen.findByTestId('sidemenu');
|
|
expect(sidemenu).toBeInTheDocument();
|
|
});
|
|
|
|
it('should not render when in kiosk mode is tv', async () => {
|
|
setup();
|
|
|
|
locationService.partial({ kiosk: 'tv' });
|
|
const sidemenu = screen.queryByTestId('sidemenu');
|
|
expect(sidemenu).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should not render when in kiosk mode is full', async () => {
|
|
setup();
|
|
|
|
locationService.partial({ kiosk: '1' });
|
|
const sidemenu = screen.queryByTestId('sidemenu');
|
|
expect(sidemenu).not.toBeInTheDocument();
|
|
});
|
|
});
|