I have functional component FilterBar -
const FilterBar=()=>{
....
....
useEffects..
states...
function apiCallToFilters()
{
...
...
}
...
..
}
Since entire code cannot be shared , I have shared a structure and a method which I want to test from jest.
I have written FilterBar.test.tsx -
describe('Filter Bar', () => {
it('All Api Calls', () => {
const wrapper = shallow(<FilterBar />);
expect(wrapper.instance().apiCallToFilters //not able to find apiCallToFilters method here
});
});
I have followed this question from SO.
After having wrapper.instance(). I am getting below properties and methods -
context
forceUpdate
getSnapshotBeforeUpdate
props
render
setState
shouldComponentUpdate
state
How can I test apiCallToFilters method in FilterBar from jest?