My component ->
export default()=>{
const [list, setList] = useState([])
const handleAddToList = () => {
//makes an api call and sets the list state.
setList(response);
}
return (
<div>
<Button onClick={hanldeAddToList}>add to list</Button>
{
list.map(row=><span>{row.name} </span>)
}
</div>
)
}
Problem =>
how to test this component using React testing library with mock list data, the problem is "list" is a state here and I cant test it using react testing library because it doesn't focus on the implementation and therefore I cant populate list state.