I need help testing the API call in Onclick Function
export function functionName (a, b, c){
const handleValue = async() =>{
axios.get(url, {method: 'post', body:{a: "a"}};
}
return <div>
{getvalue &&
<Button Onclick= {handleValue}>Button </Button>}
</div>
}
Please help me understand how to do this?
You can mock your API call using jest like:
import axios from 'axios';
jest.mock('axios');
test('your test name', () => {
axios.post.mockResolvedValue({data: yourSampleResponsePayload});
// rest of your test contents such as button click and so on
});