Created
February 20, 2017 22:56
-
-
Save ricca509/36b08b42410f1ed68e8e107aa25dd8a1 to your computer and use it in GitHub Desktop.
snapshot-component-test-1
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
// BuyNow.jsx | |
const BuyNow = ({ price, text }) => (<div> | |
<span className="price">£{price}</span> | |
<button className="btn-primary">{text}</button> | |
</div>); | |
// BuyNow.test.jsx | |
import { shallow } from 'enzyme'; | |
import BuyNow from '../BuyNow'; | |
describe('The BuyNow component', () => { | |
it('renders with the right price', () => { | |
const props = { price: 25 }; | |
const tree = shallow(<BuyNow {...props} />); | |
expect(tree.find('span').length()).toEqual(1); | |
expect(tree.find('span').text()).toEqual('£25'); | |
expect(tree.find('span').hasClass('price')).toBe(true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment