2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-14 00:42:26 +03:00

fix: when clear input(not use clear button) the date value not changed

This commit is contained in:
mxie
2018-12-19 09:51:59 +08:00
parent 454417e0b6
commit 39d2c402a3
2 changed files with 23 additions and 0 deletions
+4
View File
@@ -472,6 +472,10 @@ export default {
if (this.editable && this.userInput !== null) {
const calendar = this.$children[0]
const checkDate = calendar.isDisabledTime
if (!value) {
this.clearDate()
return
}
if (this.range) {
const range = value.split(` ${this.rangeSeparator} `)
if (range.length === 2) {
+19
View File
@@ -235,6 +235,25 @@ describe('datepicker', () => {
expect(shortcuts.exists()).toBe(false)
})
it('clear the value will set the value null', (done) => {
wrapper = mount(DatePicker, {
propsData: {
format: 'YYYY-MM-DD',
value: '2018-09-10'
},
sync: false
})
const input = wrapper.find('input')
input.setValue('')
input.trigger('input')
input.trigger('change')
Vue.nextTick(() => {
const emitted = wrapper.emitted()
expect(emitted.input).toEqual([[null]])
done()
})
})
it('type input should be right', (done) => {
wrapper = mount(DatePicker, {
propsData: {