I have a conditional rendering block in my React component which is defined as:
{(props.email.primary.isPending) ?
<PendingComponent emailAddress={props.email.primary.pendingEmail} />
:
<SecondaryEmailContact
state={props.email.secondary}
retrieveInputData={props.retrieveInputData}
handleSecondaryEmailToggle={props.handleSecondaryEmailToggle}
handleDelete={props.handleDelete}
handleSubmitContact={props.handleSubmitContact}
refs={props.refs}
/>
}
I have written a test case as below:
it('renders the EditEmailContact component', () => {
wrapper=mount(<EditEmailContact
email={emailState}
handleSecondaryEmailToggle={handleSecondaryEmailToggleFn}
retrieveInputData={retrieveInputDataFn}
handleDelete={handleDeleteFn}
handleSubmitContact={handleSubmitContactFn} />);
});
});
So, in my test result it shows the line where the statement for conditional rendering is defined is not tested. So, how do I test the conditional rendering?