Skip to content

Commit

Permalink
Add testIds in Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
chenesan committed May 12, 2020
1 parent 44546ad commit 98a71ed
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classNames from 'classnames';

import icBEM from './utils/icBEM';
import prefixClass from './utils/prefixClass';
import getTestIdProps from './utils/getTestIdProps';

import './styles/_animations.scss';
import './styles/Icon.scss';
Expand All @@ -21,6 +22,7 @@ function Icon({
large,
spinning,
className,
testIds,
...otherProps
}) {
let bemClass = ROOT_BEM
Expand All @@ -37,10 +39,13 @@ function Icon({
`gyp-icon-${type}`
);

const testIdProps = getTestIdProps(testIds);

return (
<span
className={rootClassName}
role="presentation"
{...testIdProps.icon}
{...otherProps} />
);
}
Expand All @@ -50,12 +55,16 @@ Icon.propTypes = {
color: PropTypes.oneOf([GRAY, BLUE, RED]),
large: PropTypes.bool,
spinning: PropTypes.bool,
testIds: PropTypes.shape({
icon: PropTypes.string,
}),
};

Icon.defaultProps = {
color: undefined,
large: false,
spinning: false,
testIds: {},
};

export default Icon;

0 comments on commit 98a71ed

Please sign in to comment.