Skip to content

Commit

Permalink
support complex trees
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleBertoli committed Oct 23, 2017
1 parent 733ae27 commit 5965a38
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/toHaveStyleRule.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const { getCSS } = require('./utils')

const shouldDive = node =>
typeof node.type() !== 'string' && 'innerRef' in node.props()
typeof node.dive === 'function' && typeof node.type() !== 'string'

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

const getClassNames = received => {
let className

if (received) {
if (received.$$typeof === Symbol.for('react.test.json')) {
className = received.props.className
} else if (typeof received.find === 'function') {
} else if (typeof received.findWhere === 'function') {
const tree = shouldDive(received) ? received.dive() : received
const components = tree.find('[className]')
const components = tree.findWhere(isTagWithClassName)
if (components.length) {
className = components.last().prop('className')
className = components.first().prop('className')
}
}
}
Expand Down

0 comments on commit 5965a38

Please sign in to comment.