Created
April 27, 2016 13:18
-
-
Save donaldpipowitch/22abf7da6bb7d640a8cdcc035d386667 to your computer and use it in GitHub Desktop.
React Unit Test: Shallow Rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import expect from 'expect'; | |
import ReactTestUtils from 'react-addons-test-utils'; | |
export const NameComponent = ({ name }) => <span>Hello {name}!</span>; | |
describe('name component', () => { | |
it('should render the name', () => { | |
const renderer = ReactTestUtils.createRenderer(); | |
renderer.render(<NameComponent name="foo" />); | |
const output = renderer.getRenderOutput(); | |
expect(output.type).toBe('span'); | |
expect(output.props.children).toEqual([ 'Hello ', 'foo', '!' ]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment