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

chore: Added changes from master

This commit is contained in:
Zaytsev Kirill 2020-10-18 20:45:18 +03:00
parent 049e90a128
commit bd53602f5e
4 changed files with 29 additions and 4 deletions

View File

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

View File

@ -31,6 +31,14 @@ export function shallowEqualObjects (objA: Record<string, any>, objB: Record<str
return false
}
if (objA instanceof Date && objB instanceof Date) {
return objA.getTime() === objB.getTime()
}
if (aKeys.length === 0) {
return objA === objB
}
for (let i = 0; i < aKeys.length; i++) {
const key = aKeys[i]

View File

@ -160,8 +160,6 @@ describe('FormularioForm', () => {
expect(wrapper.find('span').text()).toBe('234')
})
// ===========================================================================
/**
* @todo in vue-test-utils version 1.0.0-beta.29 has some bugs related to

View File

@ -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: `<div><span v-for="error in props.context.allErrors">{{ error.message }}</span></div>`
}
})
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)
})
})