Last active
March 14, 2017 17:44
-
-
Save IgorGee/58db781515c90784bb25796123d6664b to your computer and use it in GitHub Desktop.
Attempting to unit test with styled components
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
// Title.js | |
import styled from 'styled-components' | |
const Title = styled.h1` | |
text-align: center; | |
color: green; | |
` | |
// Home.js | |
import Title from 'components/Title' | |
const Home = () => ( | |
<div> | |
<Title>Home</Title> | |
</div> | |
) | |
// Home.test.js | |
describe('<Home />', () => { | |
let wrapper | |
beforeEach(() => { | |
wrapper = shallow(<Home />) | |
}) | |
describe('User Interface', () => { | |
it('has a Title displaying Home', () => { | |
const title = wrapper.find('Title') // Finds 0 nodes | |
console.log(title.debug()) // Nothing | |
expect(title.text()).toEqual('Home') // The api I was expecting to work | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment