I am doing unit testing using jest and enzyme on my reactjs code,where I have main functional component "TrashDisplayFiles" inside which there is a method "getDeletedData",where I have called the api which is setting TrashFileState by getting response from an api.
function TrashDisplayFiles(props){
const[TrashFileState,setTrashFileState]=useState([]);
//API CALL
useEffect(()=>{
getDeletedData();
},[]);
const getDeletedData=()=>{
trackPromise(
Axios.get(getUrl(),
{headers:{
Authorization: `Basic ${btoa(getToken())}`
}}).then((response) => {
let FileData=response.data;
setPaginationDefault(response.data.list.pagination)
setTrashFileState(response.data.list.entries.map(d=>{
return {
select:false,
id:d.entry.id,
name:d.entry.name
}}))
}).catch(err=>alert(err))
)
};
how can i unit test this setTrashFileState(response.data.list.entries.map(d=>{return{ and error alert,so that it get covers in my coverage report
also, this function is not getting simulated in my jsx through onsubmit or onclick,when the Trash page gets load ,this api gets triggered automatically.