import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import { MemoryRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { AUTH } from 'app/common/store/auth/auth.constants';
import permissions from 'app/common/config/permissions';
import { SideNav } from 'app/modules/navigation/components/sideNav';


describe('Side nav tests', () => {
  const mockStore = configureStore();

  process.env = { ADMIN_PANEL_URL:'url' };

  it('renders menu correctly for user', () => {
    const initialState = {
      user: { role: AUTH.ROLE.USER, permissions: permissions[AUTH.ROLE.USER] },
    };

    const tree = ReactTestRenderer
      .create(
        <Provider store={mockStore(initialState)}>
          <MemoryRouter>
            <SideNav onClickItemOut={jest.fn()}>
              {null}
            </SideNav>
          </MemoryRouter>
        </Provider>
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });

  it('renders menu correctly for technical manager', () => {
    const initialState = {
      user: { role: AUTH.ROLE.TECHNICAL_MANAGER, permissions: permissions[AUTH.ROLE.TECHNICAL_MANAGER] },
    };

    const tree = ReactTestRenderer
      .create(
        <Provider store={mockStore(initialState)}>
          <MemoryRouter>
            <SideNav onClickItemOut={jest.fn()}>
              {null}
            </SideNav>
          </MemoryRouter>
        </Provider>
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });

});
