mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-16 11:10:35 +03:00
fix: unable set value later when range is ture (#209)
This commit is contained in:
+6
-2
@@ -258,12 +258,16 @@ export default {
|
||||
return date.getTime()
|
||||
},
|
||||
inBefore (time, startAt) {
|
||||
startAt = startAt || this.startAt
|
||||
if (startAt === undefined) {
|
||||
startAt = this.startAt
|
||||
}
|
||||
return (this.notBeforeTime && time < this.notBeforeTime) ||
|
||||
(startAt && time < this.getCriticalTime(startAt))
|
||||
},
|
||||
inAfter (time, endAt) {
|
||||
endAt = endAt || this.endAt
|
||||
if (endAt === undefined) {
|
||||
endAt = this.endAt
|
||||
}
|
||||
return (this.notAfterTime && time > this.notAfterTime) ||
|
||||
(endAt && time > this.getCriticalTime(endAt))
|
||||
},
|
||||
|
||||
+31
-12
@@ -247,24 +247,43 @@ describe('datepicker', () => {
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
const expectDate = new Date(2018, 8, 10)
|
||||
wrapper.setProps({
|
||||
range: true
|
||||
})
|
||||
Vue.nextTick(() => {
|
||||
input.setValue('2018-09-10 ~ 2018-09-11')
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
const expectRange = [new Date(2018, 8, 10), new Date(2018, 8, 11)]
|
||||
input.setValue('2018-09-10 ~ 2018-08-10')
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
const emitted = wrapper.emitted()
|
||||
expect(emitted.input).toEqual([[expectDate], [expectRange]])
|
||||
expect(emitted['input-error']).toEqual([['2018-09-10 ~ 2018-08-10']])
|
||||
expect(emitted.input).toEqual([[expectDate]])
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('type range input should be right', (done) => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
format: 'YYYY-MM-DD',
|
||||
range: true
|
||||
},
|
||||
sync: false
|
||||
})
|
||||
const input = wrapper.find('input')
|
||||
input.setValue('2018-09-10 ~ 2018-09-11')
|
||||
input.trigger('change')
|
||||
const expectRange = [new Date(2018, 8, 10), new Date(2018, 8, 11)]
|
||||
Vue.nextTick(() => {
|
||||
input.setValue('2018-09-09 ~ 2018-09-12')
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
const expectRange2 = [new Date(2018, 8, 9), new Date(2018, 8, 12)]
|
||||
Vue.nextTick(() => {
|
||||
input.setValue('2018-09-10 ~ 2018-08-10')
|
||||
input.trigger('input')
|
||||
input.trigger('change')
|
||||
const expectError = '2018-09-10 ~ 2018-08-10'
|
||||
const emitted = wrapper.emitted()
|
||||
expect(emitted.input).toEqual([[expectRange], [expectRange2]])
|
||||
expect(emitted['input-error']).toEqual([[expectError]])
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('prop: dateFormat', () => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
|
||||
Reference in New Issue
Block a user