Skip to content

Commit

Permalink
fix(DsfrInput): 🐛 Corrige la typo sur l'attribut aria-describedby
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDASILVA committed Aug 31, 2023
1 parent b52f89d commit 566d5c9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
31 changes: 29 additions & 2 deletions src/components/DsfrInput/DsfrInput.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('DsfrInput', () => {

// When
const { getByText } = render(DsfrInput, {
stubs: ['v-icon'],
props: {
labelVisible,
label,
Expand All @@ -29,7 +28,6 @@ describe('DsfrInput', () => {

// When
const { getByText } = render(DsfrInput, {
stubs: ['v-icon'],
props: {
labelVisible,
label,
Expand All @@ -40,4 +38,33 @@ describe('DsfrInput', () => {
expect(getByText(label)).toHaveClass('fr-label')
expect(getByText(label)).toHaveClass('invisible')
})

it('should render DsfrInput with proper aria-describedby attribute if descriptionId is provided', () => {
// Given
const descriptionId = 'labelId'

// When
const { container } = render(DsfrInput, {
props: {
descriptionId,
},
})

// Then
const inputNode = container.querySelector('input')
expect(inputNode).toHaveAttribute('aria-describedby', 'labelId')
})

it('should render DsfrInput without any aria-describedby attribute if descriptionId not provided', () => {
// When
const { container } = render(DsfrInput, {
props: {
descriptionId: undefined,
},
})

// Then
const inputNode = container.querySelector('input')
expect(inputNode).not.toHaveAttribute('aria-describedby')
})
})
4 changes: 2 additions & 2 deletions src/components/DsfrInput/DsfrInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defineExpose({
'fr-input--valid': isValid,
}"
:value="modelValue"
:aria-aria-describedby="descriptionId || undefined"
:aria-describedby="descriptionId || undefined"
@input="$emit('update:modelValue', $event.target.value)"
/>

Expand All @@ -104,7 +104,7 @@ defineExpose({
'fr-input--valid': isValid,
}"
:value="modelValue"
:aria-aria-describedby="descriptionId || undefined"
:aria-describedby="descriptionId || undefined"
@input="$emit('update:modelValue', $event.target.value)"
/>
</div>
Expand Down

0 comments on commit 566d5c9

Please sign in to comment.