test: Removed checks for allErrors prop, replaced with checks for particular errors & violations
This commit is contained in:
parent
91a97e4365
commit
3cc80f20da
@ -251,7 +251,7 @@ describe('FormularioForm', () => {
|
|||||||
slots: {
|
slots: {
|
||||||
default: `
|
default: `
|
||||||
<FormularioInput v-slot="{ context }" name="fieldWithErrors">
|
<FormularioInput v-slot="{ context }" name="fieldWithErrors">
|
||||||
<span v-for="error in context.allErrors">{{ error.message }}</span>
|
<span v-for="error in context.errors">{{ error }}</span>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ describe('FormularioGrouping', () => {
|
|||||||
default: `
|
default: `
|
||||||
<FormularioGrouping name="group">
|
<FormularioGrouping name="group">
|
||||||
<FormularioInput ref="input" name="text" v-slot="{ context }">
|
<FormularioInput ref="input" name="text" v-slot="{ context }">
|
||||||
<span v-for="error in context.allErrors">{{ error }}</span>
|
<span v-for="error in context.errors">{{ error }}</span>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
</FormularioGrouping>
|
</FormularioGrouping>
|
||||||
`,
|
`,
|
||||||
|
@ -108,7 +108,7 @@ describe('FormularioInput', () => {
|
|||||||
value: 'other value'
|
value: 'other value'
|
||||||
},
|
},
|
||||||
scopedSlots: {
|
scopedSlots: {
|
||||||
default: `<div><span v-for="error in props.context.allErrors">{{ error.message }}</span></div>`
|
default: `<div><span v-for="error in props.context.violations">{{ error.message }}</span></div>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
@ -126,7 +126,7 @@ describe('FormularioInput', () => {
|
|||||||
value: 'bar'
|
value: 'bar'
|
||||||
},
|
},
|
||||||
scopedSlots: {
|
scopedSlots: {
|
||||||
default: `<div><span v-for="error in props.context.allErrors">{{ error.message }}</span></div>`
|
default: `<div><span v-for="error in props.context.violations">{{ error.message }}</span></div>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
@ -205,7 +205,7 @@ describe('FormularioInput', () => {
|
|||||||
name: 'test',
|
name: 'test',
|
||||||
validation: 'required|in:xyz|bail',
|
validation: 'required|in:xyz|bail',
|
||||||
validationBehavior: 'live',
|
validationBehavior: 'live',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
expect(wrapper.vm.context.violations.length).toBe(2);
|
expect(wrapper.vm.context.violations.length).toBe(2);
|
||||||
@ -248,45 +248,18 @@ describe('FormularioInput', () => {
|
|||||||
expect(wrapper.vm.context.violations.length).toBe(2);
|
expect(wrapper.vm.context.violations.length).toBe(2);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Does not show errors on blur when set validation-behavior is submit', async () => {
|
|
||||||
const wrapper = mount(FormularioInput, {
|
|
||||||
propsData: {
|
|
||||||
name: 'test',
|
|
||||||
validation: 'required',
|
|
||||||
validationBehavior: 'submit',
|
|
||||||
},
|
|
||||||
scopedSlots: {
|
|
||||||
default: `
|
|
||||||
<div>
|
|
||||||
<input v-model="props.context.model" @blur="props.context.runValidation()">
|
|
||||||
<span v-if="props.context.formShouldShowErrors" v-for="error in props.context.allErrors">{{ error.message }}</span>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(wrapper.find('span').exists()).toBe(false)
|
|
||||||
|
|
||||||
wrapper.find('input').trigger('input')
|
|
||||||
wrapper.find('input').trigger('blur')
|
|
||||||
|
|
||||||
await flushPromises()
|
|
||||||
|
|
||||||
expect(wrapper.find('span').exists()).toBe(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Displays errors when validation-behavior is submit and form is submitted', async () => {
|
it('Displays errors when validation-behavior is submit and form is submitted', async () => {
|
||||||
const wrapper = mount(FormularioForm, {
|
const wrapper = mount(FormularioForm, {
|
||||||
propsData: { name: 'test' },
|
propsData: { name: 'test' },
|
||||||
slots: {
|
slots: {
|
||||||
default: `
|
default: `
|
||||||
<FormularioInput
|
<FormularioInput
|
||||||
v-slot="inputProps"
|
v-slot="{ context }"
|
||||||
name="testinput"
|
name="testinput"
|
||||||
validation="required"
|
validation="required"
|
||||||
validation-behavior="submit"
|
validation-behavior="submit"
|
||||||
>
|
>
|
||||||
<span v-for="error in inputProps.context.allErrors">{{ error.message }}</span>
|
<span v-for="error in context.violations">{{ error.message }}</span>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user