Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { render } from '@testing-library/react';
- import { ErrorBoundary } from 'react-error-boundary';
- import { Provider } from 'react-redux';
- import configureStore from 'redux-mock-store';
- import { BrowserRouter as Router } from 'react-router-dom';
- import { RouterWrapper } from '../utils/test-utils';
- import Sidebar from './Sidebar';
- import { setUserRole } from '../reducers/userSlice';
- const mockStore = configureStore([]);
- describe('Sidebar Component', () => {
- let store;
- beforeEach(() => {
- store = mockStore({
- user: {
- role: 'Admin'
- },
- navigation: {
- sidebarOpen: false
- }
- });
- store.dispatch(setUserRole('Admin'));
- });
- it('renders Sidebar component with sub-navigation items based on user role', () => {
- const { getByText, queryByText } = render(
- <Provider store={store}>
- <ErrorBoundary>
- <RouterWrapper>
- <Sidebar />
- </RouterWrapper>
- </ErrorBoundary>
- </Provider>
- );
- // expect(getByText()).toBeInTheDocument();
- // expect(getByText()).toBeInTheDocument();
- // expect(queryByText()).toBeNull();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement