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.25k stars 230 forks source link

React Unit Test Case for Navigation #973

Open carmelrajtradu opened 2 months ago

carmelrajtradu commented 2 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;