diff --git a/packages/date-picker/src/panel/time-select.vue b/packages/date-picker/src/panel/time-select.vue index 56654fb0..14e8c007 100644 --- a/packages/date-picker/src/panel/time-select.vue +++ b/packages/date-picker/src/panel/time-select.vue @@ -27,6 +27,7 @@ minutes }; } + /* istanbul ignore next */ return null; }; diff --git a/test/unit/specs/time-select.spec.js b/test/unit/specs/time-select.spec.js index 7740d4aa..a54eef1f 100644 --- a/test/unit/specs/time-select.spec.js +++ b/test/unit/specs/time-select.spec.js @@ -1,4 +1,4 @@ -import { createTest, createVue } from '../util'; +import { createTest, createVue, destroyVM } from '../util'; import TimeSelect from 'packages/time-select'; import Vue from 'vue'; @@ -14,7 +14,6 @@ describe('TimeSelect', () => { }, true); const input = vm.$el.querySelector('input'); - input.blur(); input.focus(); input.blur(); @@ -23,6 +22,7 @@ describe('TimeSelect', () => { expect(vm.picker.end).to.equal('18:30'); expect(vm.picker.step).to.equal('00:15'); expect(vm.$el.querySelector('input').getAttribute('placeholder')).to.equal('test'); + destroyVM(vm); done(); }); }); @@ -44,7 +44,6 @@ describe('TimeSelect', () => { }, true); const input = vm.$el.querySelector('input'); - input.blur(); input.focus(); input.blur(); @@ -56,6 +55,7 @@ describe('TimeSelect', () => { target.click(); Vue.nextTick(_ => { expect(vm.value).to.equal(time); + destroyVM(vm); done(); }); }); @@ -67,7 +67,6 @@ describe('TimeSelect', () => { }, true); const input = vm.$el.querySelector('input'); - input.blur(); input.focus(); input.blur(); @@ -75,7 +74,65 @@ describe('TimeSelect', () => { expect(input.value).to.equal('14:30'); expect(vm.picker.$el.querySelector('.selected')).to.be.ok; expect(vm.picker.$el.querySelector('.selected').textContent).to.equal('14:30'); + destroyVM(vm); done(); - }, 500); + }, 50); + }); + + it('set minTime', done => { + const vm = createVue(` + + + `, true); + const input = vm.$el.querySelector('input'); + const picker = vm.$refs.picker; + + input.focus(); + input.blur(); + + setTimeout(_ => { + const elms = picker.picker.$el.querySelectorAll('.disabled'); + const elm = elms[elms.length - 1]; + + expect(elm.textContent).to.equal('14:30'); + destroyVM(vm); + done(); + }, 50); + }); + + it('minTime < value', done => { + const vm = createVue({ + template: ` + + + `, + data() { + return { value: '09:30' }; + } + }, true); + const input = vm.$el.querySelector('input'); + const picker = vm.$refs.picker; + + input.focus(); + input.blur(); + + setTimeout(_ => { + vm.value = '10:30'; + + setTimeout(_ => { + expect(picker.picker.value).to.equal('09:30'); + destroyVM(vm); + done(); + }, 50); + }, 50); }); });