Skip to content

Instantly share code, notes, and snippets.

@marr
Last active August 29, 2015 14:25
Show Gist options
  • Save marr/cbdb6b2bb1f38f1a9829 to your computer and use it in GitHub Desktop.
Save marr/cbdb6b2bb1f38f1a9829 to your computer and use it in GitHub Desktop.
it.only('simulates a keyPress', function() {
const KeyPressable = React.createElement('input', { onKeyPress: sinon.spy() });
const element = TestUtils.renderIntoDocument(KeyPressable);
TestUtils.Simulate.keyPress(React.findDOMNode(element), { key: 'f' });
expect(element.props.onKeyPress).to.have.been.calledOnce;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment