All files / Layout utils.js

94.11% Statements 16/17
64.28% Branches 9/14
87.5% Functions 7/8
94.11% Lines 16/17

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 27 28 29 30 31 32 33 34 35 36 37 38 39    2x 2x     281x       131x   131x 1555x 526x   131x 412x     131x               131x 786x 262x 131x   262x     131x    
import PropTypes from 'prop-types';
 
export const ColumnSizeType = PropTypes.oneOfType([PropTypes.number, PropTypes.bool]);
export const ViewportSizeType = PropTypes.oneOf(['xs', 'sm', 'md', 'lg']);
 
export function getClass(styles, className) {
  return styles && styles[className] ? styles[className] : className;
}
 
export function createProps(propTypes, props, classNames) {
  const newProps = {};
 
  Object.keys(props)
    .filter((key) => key === 'children' || !propTypes[key])
    .forEach((key) => (newProps[key] = props[key]));
 
  const className = classNames
    .filter((cn) => cn)
    .join(' ')
    .trim();
  return Object.assign({}, newProps, { className });
}
 
export function isInteger(value) {
  return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
 
export function setProps(childProps, props, values = {}) {
  Object.keys(values).forEach((value) => {
    if (props[value]) {
      if (value === 'dataId') {
        childProps['data-test-id'] = props[value];
      }
      childProps[values[value]] = props[value];
    }
  });
  return childProps;
}