Adds tests for new submit error behavior
This commit is contained in:
parent
ec0e7ac4a7
commit
289f0f262e
@ -139,7 +139,7 @@ export default {
|
||||
type: String,
|
||||
default: 'blur',
|
||||
validator: function (value) {
|
||||
return ['blur', 'live'].includes(value)
|
||||
return ['blur', 'live', 'submit'].includes(value)
|
||||
}
|
||||
},
|
||||
showErrors: {
|
||||
|
@ -2,6 +2,7 @@ import Vue from 'vue'
|
||||
import flushPromises from 'flush-promises'
|
||||
import { mount } 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'
|
||||
|
||||
@ -117,4 +118,27 @@ describe('FormulateInput', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper.contains(FormulateInputBox)).toBe(true)
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user