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 basic rendering expectations, including how props change the output. */ describe('MyComponent', () => { const getComponent = (props = {}) => { // Any test can override the default props by passing an object to the getComponent function props = Object.assign({ onChange: sinon.spy(), }, props); const component = ReactDOM.findDOMNode(TestUtils.renderIntoDocument( )); return Object.assign(props, { component }); }; it('renders a h1 for title prop', () => { const { component } = getComponent({ title: 'My Label' }); expect(component.querySelector('h1').innerText).to.equal('My Label'); }); });