-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from UKHSA-Internal/feat/CDD-2349-feedback-fi…
…eldtypes-hiddenField Feat/cdd 2349 feedback fieldtypes hidden field
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/app/components/cms/Feedback/Fields/Hidden/HiddenField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
interface HiddenFieldType { | ||
cleanName: string | ||
} | ||
|
||
export default function HiddenField({ cleanName }: Readonly<HiddenFieldType>) { | ||
return ( | ||
<input | ||
aria-label="Unused Hidden Date Input" | ||
className="govuk-visually-hidden" | ||
name={cleanName} | ||
id={cleanName} | ||
value={cleanName} | ||
/> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/components/cms/Feedback/Fields/Hidden/Hiddenfield.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<HiddenField cleanName={cleanName} />) | ||
|
||
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') | ||
}) | ||
}) |
11c17c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests coverage