mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-25 01:20:37 +03:00
test: add type input test
This commit is contained in:
+34
-10
@@ -12,7 +12,6 @@ afterEach(() => {
|
||||
wrapper.destroy()
|
||||
})
|
||||
|
||||
|
||||
describe('datepicker', () => {
|
||||
it('click: pick date', () => {
|
||||
wrapper = mount(DatePicker, {
|
||||
@@ -35,7 +34,6 @@ describe('datepicker', () => {
|
||||
td = wrapper.find('.mx-panel-date td:nth-child(5)')
|
||||
expect(td.classes()).toContain('actived')
|
||||
expect(vm.text).toBe('2018-05-03')
|
||||
|
||||
})
|
||||
|
||||
it('click: clear icon', () => {
|
||||
@@ -108,7 +106,6 @@ describe('datepicker', () => {
|
||||
})
|
||||
const vm = wrapper.vm
|
||||
expect(vm.text).toBe('2018-06-01 至 2018-06-10')
|
||||
|
||||
})
|
||||
|
||||
it('prop: confirm', () => {
|
||||
@@ -231,10 +228,40 @@ describe('datepicker', () => {
|
||||
expect(shortcuts.exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('type input should be right', (done) => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
format: 'YYYY-MM-DD'
|
||||
},
|
||||
sync: false
|
||||
})
|
||||
const input = wrapper.find('input')
|
||||
input.setValue('2018-09-10')
|
||||
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')
|
||||
expect(wrapper.emitted()).toEqual({
|
||||
input: [[expectDate], [expectRange]],
|
||||
change: [[expectDate], [expectRange]],
|
||||
'input-error': [['2018-09-10 ~ 2018-08-10']]
|
||||
})
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('calendar-panel', () => {
|
||||
|
||||
it('click: prev/next month', () => {
|
||||
wrapper = mount(CalendarPanel)
|
||||
|
||||
@@ -275,7 +302,7 @@ describe('calendar-panel', () => {
|
||||
|
||||
it('click: prev/next year', () => {
|
||||
wrapper = mount(CalendarPanel, {
|
||||
value: new Date(2018,4,5)
|
||||
value: new Date(2018, 4, 5)
|
||||
})
|
||||
const nextBtn = wrapper.find('.mx-icon-next-year')
|
||||
const lastBtn = wrapper.find('.mx-icon-last-year')
|
||||
@@ -359,7 +386,7 @@ describe('calendar-panel', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('feat: when the time panel show, scroll to the right position', () => {
|
||||
it('feat: when the time panel show, scroll to the right position', (done) => {
|
||||
wrapper = mount(CalendarPanel, {
|
||||
propsData: {
|
||||
value: new Date(2018, 4, 4),
|
||||
@@ -379,6 +406,7 @@ describe('calendar-panel', () => {
|
||||
})
|
||||
setTimeout(() => {
|
||||
expect(list.scrollTop).toBe(0)
|
||||
done()
|
||||
}, 0)
|
||||
})
|
||||
})
|
||||
@@ -393,7 +421,6 @@ describe('date-panel', () => {
|
||||
firstDayOfWeek: i
|
||||
}
|
||||
})
|
||||
const vm = wrapper.vm
|
||||
const lastMonth = new Date(2018, 3, 30)
|
||||
const lastMonthDay = 30
|
||||
const lastMonthLength = (lastMonth.getDay() + 7 - i) % 7 + 1
|
||||
@@ -456,7 +483,6 @@ describe('year-panel', () => {
|
||||
})
|
||||
|
||||
describe('time-panel', () => {
|
||||
|
||||
it('click: pick time emitted the select event', () => {
|
||||
wrapper = mount(TimePanel, {
|
||||
propsData: {
|
||||
@@ -479,7 +505,6 @@ describe('time-panel', () => {
|
||||
expect(wrapper.emitted()).toEqual({
|
||||
select: [[new Date(2018, 5, 5, 1)], [new Date(2018, 5, 5, 0, 1)], [new Date(2018, 5, 5, 0, 0, 1)]]
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
it('prop: minuteStep', () => {
|
||||
@@ -516,5 +541,4 @@ describe('time-panel', () => {
|
||||
select: [[new Date(2018, 5, 5, 1)]]
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user