How can I write a test case to test the code below using React-testing library. I have an useState which gets updated when I fill in the typeahead with some value, as soon as it gets an value then the useEffect is trigerred which calls the API - getBusinessData(). Now how can i test this api call any idea ?? I have looked over many examples but could not find any relevant solution out there which would help in this scenario.
const [UpdateName, setUpdateName] = useState({value: null, id: null});
useEffect(() => {
if (UpdateName&& UpdateName.value != null) {
SetLoaderStatus(true);
Dispatch(
getBusinessData()
).then(() => {
SetLoaderStatus(false);
})
}
}, [UpdateName])
return(
<div>
<Row>
<Col md={5}>
<span>Business Person Name</span>
<div>
<Typeahead
value={"Tom Hank}
data-testid='businesshead-data'
onChange={(value: any) => {
setUpdateName(value)
}}
/>
</div>
</Col>
<Row>
<div>
)