How to test a component which uses React Autosuggest

Viewed 329

I am trying to test a React component which is similar to the following

const MyComponent = ({ onChangCallMe, onSelectCallMe }) => {

// onChangCallMe -> sets the state of some other component  
// onSelectCallMe -> -> sets the state of some other component

return (
    <Autosuggest
        onChange={ value => onChangCallMe(value)}
        onSelect={ selected => onSelectCallMe(selected) }
    />)
}

How to test this component? and make sure that the onChangCallMe, onSelectCallMe are being called properly?

The problem is if I mock the Autosuggest like this jest.mock('./react-autosuggest') then it would not show the actual output and also it won't listen to the different events such as ChangeEvent and SelectEvent.

0 Answers
Related