Skip to content

Commit

Permalink
remove test-id when no name is given
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvanhoutte committed Aug 18, 2020
1 parent 13020cb commit f5ca8d4
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Button: React.FC<Props> = ({
type={htmlType}
onClick={isLoading || suffixIcon ? undefined : onClick}
name={name}
data-testid={`button-${name}`}
data-testid={name && `button-${name}`}
>
{isLoading ? <Spinner className={styles.spinner} /> : prefixIcon}
<span className={labelClassNames}>{children}</span>
Expand Down
4 changes: 0 additions & 4 deletions src/components/Button/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ exports[`Button default snapshot 1`] = `
<DocumentFragment>
<button
class="ventura button typePrimary"
data-testid="button-undefined"
type="button"
>
<span
Expand Down Expand Up @@ -68,7 +67,6 @@ exports[`Button prefix icon button 1`] = `
<DocumentFragment>
<button
class="ventura button typePrimary"
data-testid="button-undefined"
type="button"
>
<svg
Expand Down Expand Up @@ -99,7 +97,6 @@ exports[`Button secondary button 1`] = `
<DocumentFragment>
<button
class="ventura button typeSecondary"
data-testid="button-undefined"
type="button"
>
<span
Expand All @@ -115,7 +112,6 @@ exports[`Button suffix icon button 1`] = `
<DocumentFragment>
<button
class="ventura button typePrimary"
data-testid="button-undefined"
type="button"
>
<span
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Input = React.forwardRef<HTMLInputElement, Props>(
maxLength={maxLength}
ref={ref}
className={inputClassNames}
data-testid={`input-${name}`}
data-testid={name && `input-${name}`}
onBlur={onBlur}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/TableRow/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const TableRow: React.FC<Props> = ({ className, children, onClick, name }: Props
);

return (
<tr onClick={onClick} className={tableClassNames} data-testid={`row-${name}`}>
<tr onClick={onClick} className={tableClassNames} data-testid={name && `row-${name}`}>
{children}
</tr>
);
Expand Down
7 changes: 0 additions & 7 deletions src/components/Table/__snapshots__/Table.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ exports[`Table default snapshot 1`] = `
<tbody>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -47,7 +46,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -67,7 +65,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -87,7 +84,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -107,7 +103,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -127,7 +122,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand All @@ -147,7 +141,6 @@ exports[`Table default snapshot 1`] = `
</tr>
<tr
class="row"
data-testid="row-undefined"
>
<td
class="cellAlignLeft cell"
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const TextArea = React.forwardRef<HTMLTextAreaElement, Props>(
maxLength={maxLength}
ref={ref}
className={textareaClassNames}
data-testid={`textarea-${name}`}
data-testid={name && `textarea-${name}`}
onBlur={onBlur}
/>
);
Expand Down

0 comments on commit f5ca8d4

Please sign in to comment.