1
0
mirror of synced 2024-11-22 05:16:05 +03:00

Merge branch 'feature/error-behavior' into feature/grouping

This commit is contained in:
Justin Schroeder 2020-05-15 14:13:29 -04:00
commit 1d869936c8
2 changed files with 25 additions and 1 deletions

View File

@ -183,7 +183,7 @@ export default {
type: String,
default: 'blur',
validator: function (value) {
return ['blur', 'live'].includes(value)
return ['blur', 'live', 'submit'].includes(value)
}
},
showErrors: {

View File

@ -2,6 +2,7 @@ import Vue from 'vue'
import flushPromises from 'flush-promises'
import { mount, createLocalVue } from '@vue/test-utils'
import Formulate from '@/Formulate.js'
import FormulateForm from '@/FormulateForm.vue'
import FormulateInput from '@/FormulateInput.vue'
import FormulateInputBox from '@/inputs/FormulateInputBox.vue'
@ -292,4 +293,27 @@ describe('FormulateInput', () => {
await flushPromises();
expect(wrapper.vm.context.visibleValidationErrors.length).toBe(2);
})
it('doesnt show errors on blur when set error-behavior is submit', async () => {
const wrapper = mount(FormulateInput, { propsData: {
type: 'special',
validation: 'required',
errorBehavior: 'submit',
} })
wrapper.find('input').trigger('input')
wrapper.find('input').trigger('blur')
await flushPromises()
expect(wrapper.find('.formulate-input-errors').exists()).toBe(false)
})
it('displays errors when error-behavior is submit and form is submitted', async () => {
const wrapper = mount(FormulateForm, {
slots: {
default: `<FormulateInput error-behavior="submit" validation="required" />`
}
})
wrapper.trigger('submit')
await flushPromises()
expect(wrapper.find('.formulate-input-errors').exists()).toBe(true)
})
})