require("react-dom")
require("react-addons-test-utils");
const React = require('react');
const Component = require('react').Component;
const expect = require('chai').expect;
const shallow = require('enzyme').shallow;
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
}
render() {
return (
<div>
{this.state.counter}
<button onClick={() => this.setState({ counter: this.state.counter + 1 })} />
</div>
);
}
}
const wrapper = shallow(<MyComponent />);
expect(wrapper.text()).to.contain(0);
wrapper.find('button').simulate('click');
expect(wrapper.text()).to.contain(1);