Advertisement
shadiff

sidebar

Aug 31st, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import React from 'react';
  2. import { render } from '@testing-library/react';
  3. import { ErrorBoundary } from 'react-error-boundary';
  4. import { Provider } from 'react-redux';
  5. import configureStore from 'redux-mock-store';
  6. import { BrowserRouter as Router } from 'react-router-dom';
  7. import { RouterWrapper } from '../utils/test-utils';
  8.  
  9. import Sidebar from './Sidebar';
  10. import { setUserRole } from '../reducers/userSlice';
  11.  
  12.  
  13. const mockStore = configureStore([]);
  14.  
  15. describe('Sidebar Component', () => {
  16. let store;
  17.  
  18. beforeEach(() => {
  19. store = mockStore({
  20. user: {
  21. role: 'Admin'
  22. },
  23. navigation: {
  24. sidebarOpen: false
  25. }
  26. });
  27.  
  28. store.dispatch(setUserRole('Admin'));
  29. });
  30.  
  31. it('renders Sidebar component with sub-navigation items based on user role', () => {
  32. const { getByText, queryByText } = render(
  33. <Provider store={store}>
  34. <ErrorBoundary>
  35. <RouterWrapper>
  36. <Sidebar />
  37. </RouterWrapper>
  38. </ErrorBoundary>
  39. </Provider>
  40. );
  41.  
  42. // expect(getByText()).toBeInTheDocument();
  43. // expect(getByText()).toBeInTheDocument();
  44. // expect(queryByText()).toBeNull();
  45. });
  46. });
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement