import { expect } from 'chai'; import sinon from 'sinon'; import React from 'react'; import ReactDOM from 'react-dom'; import TestUtils from 'react-addons-test-utils'; import MyComponent from './MyComponent'; /* * Pattern to be used to assert pure interaction expectations that do not require any lifecycle hooks or internal state. */ describe('MyComponent', () => { const getComponent = (props = {}) => { props = Object.assign({ onChange: sinon.spy(), }, props); const component = ReactDOM.findDOMNode(TestUtils.renderIntoDocument( )); return Object.assign(props, { component }); }; context('when the component is changed', () => { it('calls onChange', () => { const { component, onChange } = getComponent(); const inputNode = input.querySelector('input[type=text]'); TestUtils.Simulate.change(inputNode, { target: { value: 'new' } }); expect(onChange.calledWith('new')).to.be.true; }); }); });