All files / Components Icon.js

100% Statements 6/6
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6

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      5x 232x 232x 215x       232x     5x        
import React from 'react';
import PropTypes from 'prop-types';
 
const Icon = ({ icon, className, ...props }) => {
    const addClasses = string => {
        if (typeof (string) === 'string') {
            return string.replace(/<svg/g, `<svg class="${className}"`)
        }
    }
 
    return <div dangerouslySetInnerHTML={{ __html: addClasses(icon) }} className={className} {...props} />
}
 
Icon.propTypes = {
    icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
}
 
export default Icon;