You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a little confused on how to write enzyme tests for a component that uses react-dimensions
The component looks like this:
const Show = React.createClass({
// shortened for brevity.
render () {
var width = 0.4 * this.props.containerWidth,
height = width,
radius = 0.5 * width
return (
<div>
<h1>{this.state.poll.name}</h1>
<div className="container-fluid">
// lots more stuff removed for brevity
</div>
</div>
)
}
})
export default Dimensions()(Show)
I'm trying to test it like this:
it("contains an h1 as first child", (done) => {
const wrapper = mount(<Show />);
expect(wrapper.find('h1')).to.have.length(1);
done()
});
The above test fails with AssertionError: expected { Object (component, root, ...) } to have a length of 1 but got 0
I looked at the value of wrapper.html() and get <div style="width: 100%; height: 100%; padding: 0px; border: 0px;">0</div>. I believe this touches on #28, but as things work just fine in my browser I'm confused as to why it does not behave as I would expect in my tests. Any ideas? Is there any other code I can provide that would shed light on this situation? Thanks.
I'm a little confused on how to write enzyme tests for a component that uses
react-dimensionsThe component looks like this:
I'm trying to test it like this:
The above test fails with
AssertionError: expected { Object (component, root, ...) } to have a length of 1 but got 0I looked at the value of
wrapper.html()and get<div style="width: 100%; height: 100%; padding: 0px; border: 0px;">0</div>. I believe this touches on #28, but as things work just fine in my browser I'm confused as to why it does not behave as I would expect in my tests. Any ideas? Is there any other code I can provide that would shed light on this situation? Thanks.