mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
fix(FormField): restore eager-validation prop behavior (#3031)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
committed by
Benjamin Canac
parent
00b3c86584
commit
41dc11ceef
@@ -102,7 +102,7 @@ describe('Input', () => {
|
||||
})
|
||||
|
||||
describe('form integration', async () => {
|
||||
async function createForm(validateOn?: FormInputEvents[]) {
|
||||
async function createForm(validateOn?: FormInputEvents[], eagerValidation?: boolean) {
|
||||
const wrapper = await renderForm({
|
||||
props: {
|
||||
validateOn,
|
||||
@@ -114,10 +114,13 @@ describe('Input', () => {
|
||||
}
|
||||
},
|
||||
slotTemplate: `
|
||||
<UFormField name="value">
|
||||
<UFormField name="value" :eager-validation="eagerValidation">
|
||||
<UInput id="input" v-model="state.value" />
|
||||
</UFormField>
|
||||
`
|
||||
`,
|
||||
slotVars: {
|
||||
eagerValidation
|
||||
}
|
||||
})
|
||||
const input = wrapper.find('#input')
|
||||
return {
|
||||
@@ -147,7 +150,22 @@ describe('Input', () => {
|
||||
})
|
||||
|
||||
test('validate on input works', async () => {
|
||||
const { input, wrapper } = await createForm(['input'], true)
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).toContain('Error message')
|
||||
|
||||
await input.setValue('valid')
|
||||
expect(wrapper.text()).not.toContain('Error message')
|
||||
})
|
||||
|
||||
test('validate on input without eager validation works', async () => {
|
||||
const { input, wrapper } = await createForm(['input'])
|
||||
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).not.toContain('Error message')
|
||||
|
||||
await input.trigger('blur')
|
||||
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).toContain('Error message')
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ describe('Textarea', () => {
|
||||
})
|
||||
|
||||
describe('form integration', async () => {
|
||||
async function createForm(validateOn?: FormInputEvents[]) {
|
||||
async function createForm(validateOn?: FormInputEvents[], eagerValidation?: boolean) {
|
||||
const wrapper = await renderForm({
|
||||
props: {
|
||||
validateOn,
|
||||
@@ -101,10 +101,13 @@ describe('Textarea', () => {
|
||||
}
|
||||
},
|
||||
slotTemplate: `
|
||||
<UFormField name="value">
|
||||
<UFormField name="value" :eager-validation="eagerValidation">
|
||||
<UTextarea id="input" v-model="state.value" />
|
||||
</UFormField>
|
||||
`
|
||||
`,
|
||||
slotVars: {
|
||||
eagerValidation
|
||||
}
|
||||
})
|
||||
const input = wrapper.find('#input')
|
||||
return {
|
||||
@@ -134,7 +137,22 @@ describe('Textarea', () => {
|
||||
})
|
||||
|
||||
test('validate on input works', async () => {
|
||||
const { input, wrapper } = await createForm(['input'], true)
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).toContain('Error message')
|
||||
|
||||
await input.setValue('valid')
|
||||
expect(wrapper.text()).not.toContain('Error message')
|
||||
})
|
||||
|
||||
test('validate on input without eager validation works', async () => {
|
||||
const { input, wrapper } = await createForm(['input'])
|
||||
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).not.toContain('Error message')
|
||||
|
||||
await input.trigger('blur')
|
||||
|
||||
await input.setValue('value')
|
||||
expect(wrapper.text()).toContain('Error message')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user