I need to write a test to test if the corresponding child component is rendered or not based on a prop.
To do that, I've got a component which has a child component rendered on a certain condition. Other child components are rendered without any conditional check.
To do that, in my parent component, I am receiving a prop 'renderChild'.
If 'renderChild' is true, then render the child component.
For e.g., in my ReactJS, in the ParentComponent :
return {
    <div>
    { props.renderChild && <ChildComponent {...childProps} /> }
        <ChildComponent2 {...childProps2 } />
    </div>
}
Now, here's the test I've written :
const parentProps = {
    renderChild: true;
    name: "parent",
    message: "Hello Parent"
};
const childProps = {
  name: "child1",
  message: "Hello child1"   
};
test('childComponent should be rendered if renderChild is true', () => {
    const childComponent = shallow(<ChildComponent {...childProps} />);
    expect(childComponent).toMatchSnapshot();
});
Could you please help me achieve this?
 
    