lundi 22 juin 2020

Set state of redux connected react component using enzyme

import configureMockStore from 'redux-mock-store';
import NavBar from '../components/NavBar/NavBar';

const mockStore = configureMockStore(middlewares);
const store = mockStore(initialState);

wrapper = mount(
            <BrowserRouter> 
                <Provider store={store}>
                <NavBar {...props} />
                </Provider>
            </BrowserRouter> 
        );

How to update the state of NavBar component which is present in wrapper? I tried updating using wrapper.setState({displayMenu:true}) method but not updated because I think wrapper is wrap of component with Provider. So state of NavBar is not updated. Please help

Aucun commentaire:

Enregistrer un commentaire