1
0
mirror of synced 2025-01-31 14:51:41 +03:00

Adds tests for new submit error behavior

This commit is contained in:
Justin Schroeder 2020-03-11 22:01:18 -04:00
parent ec0e7ac4a7
commit 289f0f262e
2 changed files with 25 additions and 1 deletions

View File

@ -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: {

View File

@ -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)
})
})