Created
April 27, 2016 13:31
-
-
Save donaldpipowitch/341e85d336cf6b36e8e4cb3915799a8d to your computer and use it in GitHub Desktop.
React Unit Test: Shallow Rendering with Enzyme
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 { shallow } from 'enzyme'; | |
export const NameComponent = ({ name }) => <span>Hello {name}!</span>; | |
describe('name component', () => { | |
it('should render the name', () => { | |
const wrapper = shallow(<NameComponent name="foo" />); | |
expect(wrapper.type()).toBe('span'); | |
expect(wrapper.props().children).toEqual([ 'Hello ', 'foo', '!' ]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment