Skip to content

Commit

Permalink
exclude empty nodes
Browse files Browse the repository at this point in the history
fix #189
  • Loading branch information
MicheleBertoli committed Sep 22, 2018
1 parent 2df3f60 commit 403d999
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/toHaveStyleRule.js
Expand Up @@ -4,7 +4,7 @@ const shouldDive = node =>
typeof node.dive === 'function' && typeof node.type() !== 'string'

const isTagWithClassName = node =>
node.prop('className') && typeof node.type() === 'string'
node.exists() && node.prop('className') && typeof node.type() === 'string'

const getClassNames = received => {
let className
Expand Down
13 changes: 13 additions & 0 deletions test/toHaveStyleRule.spec.js
Expand Up @@ -471,3 +471,16 @@ test('nested', () => {

toHaveStyleRule(<MyComponent />, 'background', 'papayawhip')
})

test('empty children', () => {
const Wrapper = styled.section`
padding: 4em;
background: papayawhip;
`

Wrapper.defaultProps = {
children: '',
}

toHaveStyleRule(<Wrapper />, 'background', 'papayawhip')
})

0 comments on commit 403d999

Please sign in to comment.