All files / react-native-mock/src createMockComponent.js

100% Statements 11/11
57.14% Branches 4/7
100% Functions 1/1
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231x     13x 13x 13x   121x   54x               13x 13x   13x    
import React from 'react';
 
export default name => {
  const RealComponent = require(name);
  const realComponentName = RealComponent.name === 'Component' ? name : RealComponent.name;
  const componentName = (RealComponent.displayName || realComponentName || name).replace(/^(RCT|RK)/, '');
 
  const Component = class extends RealComponent {  // eslint-disable-line react/prefer-stateless-function
    render() {
      return React.createElement(
        componentName,
        this.props,
        this.props.children
      );
    }
  };
 
  Component.displayName = componentName;
  Component.name = componentName;
 
  return Component;
};