Skip to content

Commit

Permalink
chore: add data-test attr on stacks (#5192)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmainguytalend authored Feb 16, 2024
1 parent ca74483 commit c1c9c5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/four-islands-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/design-system': minor
---

chore: add data-test attr on stacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from '@jest/globals';
import { render, screen } from '@testing-library/react';

import StackPrimitive from './StackPrimitive';

describe('StackPrimitive', () => {
it('Should render with data-test attributes', async () => {
render(
<StackPrimitive
data-test="my-stack"
data-testid="my-stack-testid"
data-feature="my-stack-feature"
gap={0}
>
text
</StackPrimitive>,
);

const stack = screen.getByTestId('my-stack-testid');
expect(stack).toBeInTheDocument();

expect(stack).toHaveAttribute('data-test', 'my-stack');
expect(stack).toHaveAttribute('data-feature', 'my-stack-feature');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { ReactNode, Ref } from 'react';

import classnames from 'classnames';

import { DataAttributes } from '../../../types';

import styles from './StackPrimitive.module.scss';

export const justifyOptions = {
Expand Down Expand Up @@ -112,7 +114,7 @@ export type StackPrimitiveProps = {
isFullWidth?: boolean;
noShrink?: boolean;
noGrow?: boolean;
};
} & DataAttributes;

const StackPrimitive = forwardRef(function StackPrimitive(
{
Expand Down

0 comments on commit c1c9c5a

Please sign in to comment.