chore(Form): catch-up with v2 changes (#2165)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2024-09-10 14:09:42 +02:00
committed by GitHub
parent 9ddfec123e
commit 175229384f
8 changed files with 33 additions and 21 deletions

View File

@@ -228,7 +228,7 @@ describe('Form', () => {
expect(passwordField.text()).toBe('Required')
})
test('valid submit works', async () => {
test('validate on submit works', async () => {
state.email = 'bob@dylan.com'
state.password = 'strongpassword'
@@ -236,6 +236,7 @@ describe('Form', () => {
expect(wrapper.setupState.onSubmit).toHaveBeenCalledTimes(1)
expect(wrapper.setupState.onSubmit).toHaveBeenCalledWith(expect.objectContaining({
type: 'submit',
data: {
email: 'bob@dylan.com',
password: 'strongpassword'

View File

@@ -72,7 +72,7 @@ describe('RadioGroup', () => {
items: ['Option 1', 'Option 2']
},
slotTemplate: `
<UFormField name="value">
<UFormField name="value" label="Radio group">
<URadioGroup id="input" v-model="state.value" :items="items" />
</UFormField>
`
@@ -107,5 +107,11 @@ describe('RadioGroup', () => {
await flushPromises()
expect(wrapper.text()).not.toContain('Error message')
})
test('no label for=... on FormField', async () => {
const { wrapper } = await createForm()
const formFieldLabel = wrapper.findAll('label').map(label => label.attributes()).filter(label => !label.for?.includes('Option'))[0]
expect(formFieldLabel.for).toBeUndefined()
})
})
})