Merge pull request #5 from 1on/fixes
Fixed shallowEqualObjects on Date and removed field validation on created
This commit is contained in:
commit
2373c1559f
@ -183,7 +183,9 @@ export default {
|
|||||||
this.observeErrors({ callback: this.setErrors, type: 'input', field: this.nameOrFallback })
|
this.observeErrors({ callback: this.setErrors, type: 'input', field: this.nameOrFallback })
|
||||||
}
|
}
|
||||||
this.updateLocalAttributes(this.$attrs)
|
this.updateLocalAttributes(this.$attrs)
|
||||||
|
if (this.errorBehavior === 'live') {
|
||||||
this.performValidation()
|
this.performValidation()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
if (!this.disableErrors && typeof this.removeErrorObserver === 'function') {
|
if (!this.disableErrors && typeof this.removeErrorObserver === 'function') {
|
||||||
|
@ -33,6 +33,14 @@ export function shallowEqualObjects (objA, objB) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objA instanceof Date && objB instanceof Date) {
|
||||||
|
return objA.getTime() === objB.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len === 0) {
|
||||||
|
return objA === objB;
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
var key = aKeys[i]
|
var key = aKeys[i]
|
||||||
|
|
||||||
|
@ -136,6 +136,31 @@ describe('FormularioForm', () => {
|
|||||||
expect(wrapper.vm.formValues).toEqual({ testinput: 'edited value' })
|
expect(wrapper.vm.formValues).toEqual({ testinput: 'edited value' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('field data updates when it is type of date', async () => {
|
||||||
|
const wrapper = mount({
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
formValues: {
|
||||||
|
testdate: new Date(123),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<FormularioForm v-model="formValues" ref="form">
|
||||||
|
<FormularioInput v-slot="inputProps" name="testdate" >
|
||||||
|
<span v-if="inputProps.context.model">{{ inputProps.context.model.getTime() }}</span>
|
||||||
|
</FormularioInput>
|
||||||
|
</FormularioForm>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
expect(wrapper.find('span').text()).toBe('123')
|
||||||
|
|
||||||
|
wrapper.setData({ formValues: { testdate: new Date(234) } })
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
expect(wrapper.find('span').text()).toBe('234')
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -44,6 +44,22 @@ describe('FormularioInput', () => {
|
|||||||
expect(wrapper.find('span').text()).toBe('the value was different than expected')
|
expect(wrapper.find('span').text()).toBe('the value was different than expected')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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('allows custom field-rule level validation functions', async () => {
|
it('allows custom field-rule level validation functions', async () => {
|
||||||
const wrapper = mount(FormularioInput, {
|
const wrapper = mount(FormularioInput, {
|
||||||
propsData: {
|
propsData: {
|
||||||
@ -268,6 +284,9 @@ describe('FormularioInput', () => {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
await flushPromises()
|
||||||
|
expect(wrapper.find('span').exists()).toBe(false)
|
||||||
|
|
||||||
wrapper.trigger('submit')
|
wrapper.trigger('submit')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user