Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Created May 19, 2015 16:12
Show Gist options
  • Save jhollingworth/c565a556f6ad31506985 to your computer and use it in GitHub Desktop.
Save jhollingworth/c565a556f6ad31506985 to your computer and use it in GitHub Desktop.
let TestUtils = require("react/addons").addons.TestUtils;
class LoginPage extends React.Component {
render() {
return (
<form className="LoginPage">
<input type="email" value={this.state.email} />
<input type="password" value={this.state.password} />
<input type="submit" value="Login" />
</form>
);
}
}
let element = TestUtils.renderIntoDocument(<LoginPage />);
let emailNode = element.email.getDOMNode();
expect(emailNode.value).to.equal("[email protected]");
// Potentially multiple ways to change the value
element.password.getDOMNode().value = "[email protected]";
TestUtils.Simulate.change(element.password.getDOMNode(), {
target: {
value: "password"
}
});
TestUtils.Simulate.click(element.login.getDOMNode());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment