import React from 'react' import { render } from '@testing-library/react' import { FieldMessage, type FieldMessageProps } from './FieldMessage' const defaultFieldMessageProps = { id: 'someFieldMessageId', message: 'Some FieldMessage.', } const FieldMessageWrapper = (props: Partial): JSX.Element => ( ) describe('', () => { it('renders a message within a

tag when given a string', () => { const { getByText } = render() const labelContainer = getByText('Hello I am a message') expect(labelContainer).toBeInTheDocument() expect(labelContainer?.tagName === 'P').toBeTruthy() }) it('renders a message within a

tag when not given node other than string', () => { const { getByText } = render( Hello I am a message within a span} />, ) const labelContainer = getByText('Hello I am a message within a span') expect(labelContainer).toBeInTheDocument() expect(labelContainer?.tagName === 'SPAN').toBeTruthy() expect(labelContainer?.parentElement?.tagName === 'DIV').toBeTruthy() }) it('renders an `id` attribute', () => { const { getByTestId } = render( , ) expect(getByTestId('id--fieldMessage')).toHaveAttribute('id', 'id--test') }) it('renders the error icon with an accessible title', () => { const { getByLabelText } = render() expect(getByLabelText('error message')).toBeInTheDocument() }) it('renders the caution icon with an accessible title', () => { const { getByLabelText } = render() expect(getByLabelText('caution message')).toBeInTheDocument() }) })