Skip to content

Commit

Permalink
add some test ids
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoskolodny committed Oct 17, 2024
1 parent 439300d commit d46648f
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 53 deletions.
30 changes: 24 additions & 6 deletions src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const renderButtonContent = ({
alignItems: 'center',
marginRight: styles.iconMargin,
}}
data-testid="startIcon"
>
<StartIcon size={defaultIconSize} color="currentColor" />
</div>
Expand All @@ -201,6 +202,7 @@ const renderButtonContent = ({
alignItems: 'center',
marginLeft: styles.iconMargin,
}}
data-testid="endIcon"
>
<EndIcon size={defaultIconSize} color="currentColor" />
</div>
Expand Down Expand Up @@ -249,7 +251,11 @@ const renderButtonContent = ({
}}
/>
)}
{loadingText ? <Box paddingLeft={8}>{loadingButtonElement}</Box> : null}
{loadingText ? (
<Box paddingLeft={8} dataAttributes={{testid: 'loadingText'}}>
{loadingButtonElement}
</Box>
) : null}
</div>
</>
);
Expand Down Expand Up @@ -513,7 +519,7 @@ export const ButtonLink = React.forwardRef<
>(({dataAttributes, className, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonLink', ...dataAttributes}}
dataAttributes={{'component-name': 'ButtonLink', testid: 'ButtonLink', ...dataAttributes}}
className={classnames(className, {[styles.smallLink]: props.small})}
{...props}
ref={ref}
Expand All @@ -526,7 +532,11 @@ export const ButtonLinkDanger = React.forwardRef<TouchableElement, ButtonLinkPro
({dataAttributes, className, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonLinkDanger', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonLinkDanger',
testid: 'ButtonLinkDanger',
...dataAttributes,
}}
className={classnames(className, {[styles.smallLink]: props.small})}
{...props}
withChevron={false}
Expand All @@ -541,7 +551,11 @@ export const ButtonPrimary = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonPrimary', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonPrimary',
testid: 'ButtonPrimary',
...dataAttributes,
}}
{...props}
ref={ref}
buttonType="primary"
Expand All @@ -554,7 +568,11 @@ export const ButtonSecondary = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonSecondary', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonSecondary',
testid: 'ButtonSecondary',
...dataAttributes,
}}
{...props}
ref={ref}
buttonType="secondary"
Expand All @@ -567,7 +585,7 @@ export const ButtonDanger = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonDanger', ...dataAttributes}}
dataAttributes={{'component-name': 'ButtonDanger', testid: 'ButtonDanger', ...dataAttributes}}
{...props}
ref={ref}
buttonType="danger"
Expand Down
Loading

0 comments on commit d46648f

Please sign in to comment.