Fixed shallowEqualObjects on Date
This commit is contained in:
parent
ef285012fa
commit
f53738dac3
@ -33,6 +33,14 @@ export function shallowEqualObjects (objA, objB) {
|
||||
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++) {
|
||||
var key = aKeys[i]
|
||||
|
||||
|
@ -136,6 +136,31 @@ describe('FormularioForm', () => {
|
||||
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')
|
||||
})
|
||||
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user