I am trying to press enter on one of the input boxes. Doing it manually triggers the event listener, however, while trying with enzyme, the event listener is not triggered. What am I doing wrong here?
Event Listener
this.input.addEventListener('keypress', function(event){
debugger;
onEnter(event);
});
Enzyme
function setup(store, props) {
return mount(<Provider store={store}>
<component{...props}/>
</Provider>
);
}
beforeEach(() => {
wrapper = setup(store, {});
searchBar = wrapper.find('searchBar');
searchInput = searchBar.find("input");
});
it("when enter is pressed, event should be triggered", ()=> {
let wait = false;
runs(()=> {
searchInput.simulate('change', {target: {value: 'helloWorld'}});
searchInput.simulate('keyPress', {which: 13});
setTimeout(()=> {
wait = true;
}, 1000);
})
waitsFor(()=> {
return wait;
}, "", 1500);
})
Aucun commentaire:
Enregistrer un commentaire