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>
);
it('renders name field', () =>
const nameField = wrapper.find('[name="name"]'); //value of this input is "HandlerName 2"
nameField.simulate('change', {target: {name:"name", value: 'HandlerName'}});
//value of name property in state is modified which is found using console.log() in onChange method in component
//But below TEST FAILED after update of input shows previous value only even modified in state
expect(nameField.props().value).toBe('HandlerName'); //failed shows value="HandlerName 2"
);
I am unable to find the reason why testcase is failed in this code.
Please read the comments in the above code for more understanding
How to check whether state is modified in that component?
Aucun commentaire:
Enregistrer un commentaire