Created
August 2, 2017 20:40
-
-
Save MrRhodes/8b026cdc92841d643debba1b89050d3f to your computer and use it in GitHub Desktop.
Should not find conditionally rendered child?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
class ConditionalParent extends React.Component { | |
render() { | |
return !!this.props.visible && (<div>{this.props.children}</div>); | |
} | |
} | |
class Child extends React.Component { | |
render() { | |
return <div>Hello</div>; | |
} | |
} | |
it('should have no child.', () => { | |
const wrapper = shallow( | |
<div> | |
<ConditionalParent> | |
<Child /> | |
</ConditionalParent> | |
</div> | |
); | |
expect(wrapper.find(Child).length).toBe(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment