testing-library / react-hooks-testing-library

🐏 Simple and complete React hooks testing utilities that encourage good testing practices.
https://react-hooks-testing-library.com
MIT License
5.26k stars 233 forks source link

React Unit Test Case for Navigation #973

Open carmelrajtradu opened 5 months ago

carmelrajtradu commented 5 months ago

I need some ones help to write a unit test for this code. I have write a test case but its not working. I can't copy and past original so I have created dummy code and pasted it.

import {useState, useEffect} from 'React'; import {useNavigate} from 'react-router-dom'; import {useSelector} from 'react-redux'; const componentName=()=>{ const navigate = useNavigate(); const {loginRes} = useSelector((state).signUp) const [data, setData] = useState()

useEffect(()=>{
    if(loginRes.autoRejection){
        navigate('/rejection')
    }else{
        navigate('/docUpload')
    }
},[loginRes])

} export default componentName;