From bd53602f5e10f1f9d3dec1ce2134cc6001d92b11 Mon Sep 17 00:00:00 2001 From: Zaytsev Kirill Date: Sun, 18 Oct 2020 20:45:18 +0300 Subject: [PATCH] chore: Added changes from master --- src/FormularioInput.vue | 4 +++- src/libs/utils.ts | 8 ++++++++ test/unit/FormularioForm.test.js | 2 -- test/unit/FormularioInput.test.js | 19 ++++++++++++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/FormularioInput.vue b/src/FormularioInput.vue index c08d19e..e40cb6d 100644 --- a/src/FormularioInput.vue +++ b/src/FormularioInput.vue @@ -303,7 +303,9 @@ export default class FormularioInput extends Vue { this.addErrorObserver({ callback: this.setErrors, type: 'input', field: this.nameOrFallback }) } this.updateLocalAttributes(this.$attrs) - this.performValidation() + if (this.errorBehavior === ERROR_BEHAVIOR.LIVE) { + this.performValidation() + } } // noinspection JSUnusedGlobalSymbols diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 2bdd2bc..7ce3513 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -31,6 +31,14 @@ export function shallowEqualObjects (objA: Record, objB: Record { expect(wrapper.find('span').text()).toBe('234') }) - - // =========================================================================== /** * @todo in vue-test-utils version 1.0.0-beta.29 has some bugs related to diff --git a/test/unit/FormularioInput.test.js b/test/unit/FormularioInput.test.js index 16e100f..81057ce 100644 --- a/test/unit/FormularioInput.test.js +++ b/test/unit/FormularioInput.test.js @@ -75,6 +75,22 @@ describe('FormularioInput', () => { expect(wrapper.find('span').text()).toBe('The string other value is not correct.') }) + it('no validation on created when errorBehavior is not live', async () => { + const wrapper = mount(FormularioInput, { + propsData: { + name: 'test', + validation: 'required|in:abcdef', + validationMessages: {in: 'the value was different than expected'}, + value: 'other value' + }, + scopedSlots: { + default: `
{{ error.message }}
` + } + }) + await flushPromises() + expect(wrapper.find('span').exists()).toBe(false) + }) + it('uses custom async validation rules on defined on the field', async () => { const wrapper = mount(FormularioInput, { propsData: { @@ -282,12 +298,13 @@ describe('FormularioInput', () => { ` } }) + await flushPromises() expect(wrapper.find('span').exists()).toBe(false) wrapper.trigger('submit') - await flushPromises() + await flushPromises() expect(wrapper.find('span').exists()).toBe(true) }) })