Last active
September 18, 2018 14:30
-
-
Save maecapozzi/946ac35b1f654a0525ba4312e73cd174 to your computer and use it in GitHub Desktop.
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
// Imagine your application code looks like this | |
const Button = styled.button` | |
color: ${props => props.theme.main}; | |
` | |
const theme = { | |
main: 'mediumseagreen', | |
} | |
// You can test it like this | |
import React from 'react'; | |
import 'jest-styled-components'; | |
import { shallow } from 'enzyme'; | |
describe('<Button />', () => { | |
it('applies default styles', () => { | |
const theme = { | |
main: 'mediumseagreen', | |
} | |
const wrapper = shallow(<Button theme={theme} />) | |
expect(wrapper).toHaveStyleRule('main', 'mediumseagreen'); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment