import React from 'react'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { TextArea } from './'; describe('TextArea component', () => { const value = 'abc'; const onChange = vi.fn(); describe('given an `id` props', () => { it('adds the `id` from props textarea component', () => { render(); expect(screen.getByRole('textbox')).toHaveAttribute('id', 'my-input'); }); }); describe('given a `isDisabled` props', () => { it('adds the `isDisabled` from props to the textarea component', () => { render(); expect(screen.getByRole('textbox')).toBeDisabled(); }); }); describe('given a `name` props', () => { it('adds the `name` from props to the textarea component', () => { render(); expect(screen.getByRole('textbox')).toHaveAttribute('name', 'first-name'); }); }); describe('given a `placeholder` props', () => { it('adds the `placeholder` from props to the textarea component', () => { render( , ); expect(screen.getByPlaceholderText('Write something')).toBeVisible(); }); }); describe('given accessibility props', () => { it('can be accessible using aria-label', () => { render( , ); expect(screen.getByRole('textbox', { name: 'myLabel' })).toBeVisible(); }); it('can be accessible using aria-labelledby', () => { render(
myLabel
,