diff --git a/.changeset/fuzzy-ears-occur.md b/.changeset/fuzzy-ears-occur.md new file mode 100644 index 00000000000..396b4ad300c --- /dev/null +++ b/.changeset/fuzzy-ears-occur.md @@ -0,0 +1,5 @@ +--- +"@utrecht/component-library-react": minor +--- + +Add `FormFieldTextarea` component to the React component library. diff --git a/packages/component-library-react/src/FormFieldTextarea.test.tsx b/packages/component-library-react/src/FormFieldTextarea.test.tsx new file mode 100644 index 00000000000..d13f8284a3e --- /dev/null +++ b/packages/component-library-react/src/FormFieldTextarea.test.tsx @@ -0,0 +1,826 @@ +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { createRef } from 'react'; +import { FormFieldTextarea } from './FormFieldTextarea'; +import '@testing-library/jest-dom'; + +describe('Form field with a textarea', () => { + const defaultProps = { + name: 'subject', + label: 'Subject', + }; + + it('renders an HTML div element', () => { + const { container } = render(); + + const field = container.querySelector('div'); + + expect(field).toBeInTheDocument(); + }); + + it('renders a design system BEM class name: utrecht-form-field', () => { + const { container } = render(); + + const field = container.querySelector('div'); + + expect(field).toHaveClass('utrecht-form-field'); + }); + + it('displays as CSS block element (or equivalent)', () => { + const { container } = render(); + + const field = container.querySelector('div'); + + expect(field).toBeVisible(); + expect(field).not.toHaveStyle({ display: 'inline' }); + expect(field).not.toHaveStyle({ display: 'inline-block' }); + }); + + it('renders rich text content', () => { + const { container } = render( + +
+
, + ); + + const richText = container.querySelector('hr'); + + expect(richText).toBeInTheDocument(); + }); + + it('can be hidden', () => { + const { container } = render(