Last active
October 21, 2015 07:41
-
-
Save vvo/b4afa17a77f6cc5c0eaf to your computer and use it in GitHub Desktop.
Shallow rendering example
This file contains 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'; | |
class Label extends React.Component { | |
render() { | |
return <span>Hello {this.props.name}</span>; | |
} | |
} | |
export default Label; |
This file contains 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 {createRenderer} from 'react-addons-test-utils'; | |
import Button from './Button.js'; | |
import Label from './Label.js'; | |
describe('Button', () => { | |
it('works', () => { | |
let renderer = createRenderer(); | |
renderer.render(<Button name="John" />); | |
let actualElement = renderer.getRenderOutput(); | |
let expectedElement = <div><Label name="John" /></div>; | |
expect(actualElement).toEqual(expectedElement); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment