All files mapChildren.js

100% Statements 8/8
100% Branches 8/8
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x     38x   14x       14x             24x       17x 38x       1x  
const React = require('react')
 
function mapChild(child, i, depth) {
  if (child.tagName) {
    const className =
      child.properties && Array.isArray(child.properties.className)
        ? child.properties.className.join(' ')
        : child.properties.className
 
    return React.createElement(
      child.tagName,
      Object.assign({key: `fract-${depth}-${i}`}, child.properties, {className}),
      child.children && child.children.map(mapWithDepth(depth + 1))
    )
  }
 
  return child.value
}
 
function mapWithDepth(depth) {
  return function mapChildrenWithDepth(child, i) {
    return mapChild(child, i, depth)
  }
}
 
exports.depth = mapWithDepth