diff --git a/src/app/components/cms/Feedback/Fields/Hidden/HiddenField.tsx b/src/app/components/cms/Feedback/Fields/Hidden/HiddenField.tsx new file mode 100644 index 00000000..7d45d452 --- /dev/null +++ b/src/app/components/cms/Feedback/Fields/Hidden/HiddenField.tsx @@ -0,0 +1,15 @@ +interface HiddenFieldType { + cleanName: string +} + +export default function HiddenField({ cleanName }: Readonly) { + return ( + + ) +} diff --git a/src/app/components/cms/Feedback/Fields/Hidden/Hiddenfield.spec.tsx b/src/app/components/cms/Feedback/Fields/Hidden/Hiddenfield.spec.tsx new file mode 100644 index 00000000..6bdebf6e --- /dev/null +++ b/src/app/components/cms/Feedback/Fields/Hidden/Hiddenfield.spec.tsx @@ -0,0 +1,19 @@ +import { render, screen } from '@/config/test-utils' + +import HiddenField from './HiddenField' + +describe('HiddenField component', () => { + test('renders a hidden input with the correct attributes', () => { + const cleanName = 'userId' + + render() + + const inputElement = screen.getByRole('textbox') + expect(inputElement).toBeInTheDocument() + expect(inputElement).toHaveAttribute('name', cleanName) + expect(inputElement).toHaveAttribute('id', cleanName) + expect(inputElement).toHaveAttribute('value', cleanName) + expect(inputElement).toHaveClass('govuk-visually-hidden') + expect(inputElement).toHaveAttribute('aria-label', 'Unused Hidden Date Input') + }) +})