Skip to content

Commit

Permalink
fix(Icon): add testID prop (react-native-elements#3787)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisLau authored Jun 7, 2023
1 parent 1ddc630 commit a13b22b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/base/src/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export type IconType =
| string;

export interface IconObject {
/** Test ID of icon. */
testID?: string;

/** Name of icon. */
name?: string;

Expand All @@ -58,6 +61,9 @@ export interface IconObject {
export type IconNode = boolean | React.ReactElement<{}> | Partial<IconProps>;

export interface IconProps extends InlinePressableProps, IconButtonProps {
/** Test ID of icon. */
testID?: string;

/** Type of icon set. [Supported sets here](#available-icon-sets). */
type?: IconType;

Expand Down Expand Up @@ -97,6 +103,7 @@ export interface IconProps extends InlinePressableProps, IconButtonProps {
/** Icons are visual indicators usually used to describe action or intent.
* They are also used for displaying information. */
export const Icon: RneFunctionComponent<IconProps> = ({
testID = 'RNE__ICON__CONTAINER',
type = 'material',
name,
size = 24,
Expand Down Expand Up @@ -146,6 +153,7 @@ export const Icon: RneFunctionComponent<IconProps> = ({

return (
<View
testID={testID}
style={StyleSheet.flatten([
!raised && styles.container,
(reverse || raised) && styles.button,
Expand All @@ -158,7 +166,6 @@ export const Icon: RneFunctionComponent<IconProps> = ({
: {},
containerStyle && containerStyle,
])}
testID="RNE__ICON__CONTAINER"
>
<Component
testID="RNE__ICON__CONTAINER_ACTION"
Expand Down

0 comments on commit a13b22b

Please sign in to comment.