Skip to content

Instantly share code, notes, and snippets.

@maecapozzi
Last active September 18, 2018 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maecapozzi/946ac35b1f654a0525ba4312e73cd174 to your computer and use it in GitHub Desktop.
Save maecapozzi/946ac35b1f654a0525ba4312e73cd174 to your computer and use it in GitHub Desktop.
// 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