I have the following code:
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
const LoggedOutRoute = ({ component: Component, isLoggedIn, ...rest }) => (
<Route render={() => (
!isLoggedIn
? <Component {...rest} />
: <Redirect to='/home' />
)} />
)
export default LoggedOutRoute;
with this particular test for the '!isLoggedIn' part:
test('The props renders accordingly', () => {
const loginComponent = shallow(<LoggedOutRoute isLoggedIn={true}/>)
loginComponent.setProps({isLoggedIn: true})
expect(loginComponent).toExist
})
the test is running and passing but the coverage is not showing 100% for this component because it's stating that line 6 '!isLoggedIn' is uncovered. Could anyone help me with this test so nyc covers it?
Aucun commentaire:
Enregistrer un commentaire