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

Fixed shallowEqualObjects on Date

This commit is contained in:
1on 2020-10-16 10:52:40 +03:00
parent ef285012fa
commit f53738dac3
2 changed files with 33 additions and 0 deletions

View File

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

View File

@ -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')
})
// ===========================================================================