Skip to content

Commit

Permalink
test(FormField): add label bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
romhml committed Jan 17, 2025
1 parent ab19c18 commit 207b4aa
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/components/FormField.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,32 @@ describe('FormField', () => {
expect(html).toMatchSnapshot()
})

describe.each(inputComponents.map(inputComponent => [(inputComponent as any).__name, inputComponent]))('%s integration', async (_: string, inputComponent: any) => {
describe.each(inputComponents.map(inputComponent => [(inputComponent as any).__name, inputComponent]))('%s integration', async (name: string, inputComponent: any) => {
if (name === 'RadioGroup') {
test('unbinds label for', async () => {
const wrapper = await renderFormField({
props: { label: 'Label' },
inputComponent
})

const label = wrapper.find('label[for=v-0-0]')
expect(label.exists()).toBe(false)
})
} else {
test('binds label for', async () => {
const wrapper = await renderFormField({
props: { label: 'Label' },
inputComponent
})

const label = wrapper.find('label[for=v-0-0]')
expect(label.exists()).toBe(true)

const input = wrapper.find('[id=v-0-0]')
expect(input.exists()).toBe(true)
})
}

test('binds hints with aria-describedby', async () => {
const wrapper = await renderFormField({
props: { hint: 'somehint' },
Expand Down

0 comments on commit 207b4aa

Please sign in to comment.