This is just an example and I have all the necessary imports and all the code. The code inside the if-else blocks was not getting covered while writing test cases.
function MyComponent() {
const title = '';
if (window.location.pathname === '/dashboard') {
title= "dashboard"
} else if (window.location.pathname === '/home') {
title= "home"
} else if (window.location.pathname === '/about') {
title= "about"
}
return(
<h1>{title}</h1>
)
}