DEV Community

Vasantha Kumar G
Vasantha Kumar G

Posted on

Jest test case for custom hook

If you have a custom hook, which does not accept parameters, inside that you get some config via some other hooks based on that, you made graphql query and based on that result, you redirect the page by useHistory hook. Now how to pass your values inside that hook(bcz no params). How could you write the jest test case for this hook?
the code base of hook is like below:

function useCity(){
const history = useHistory()
const {user, vehicle} = usePageConfig()
cosnt {data,error} = getVehicleDetailsQuery({
variables: { userId: userId, bankerId: userId },
})
if(data.vehicle.includes('TN')){
history.push('tnView')
}
if(error){
history.push('seaView')
}

Top comments (0)