|
|
@ -18,22 +18,24 @@ describe('DatePicker', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
it('should focus trigger input after select date in DatePicker', () => { |
|
|
|
const wrapper = mount(<DatePicker />); |
|
|
|
const wrapper = mount(<DatePicker />, { attachTo: document.body }); |
|
|
|
openPanel(wrapper); |
|
|
|
selectDate(wrapper, moment('2016-11-23')); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).toBe(document.activeElement); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should focus trigger input after select date in RangePicker', () => { |
|
|
|
const wrapper = mount(<RangePicker />); |
|
|
|
const wrapper = mount(<RangePicker />, { attachTo: document.body }); |
|
|
|
openPanel(wrapper); |
|
|
|
selectDate(wrapper, moment('2016-11-23'), 0); |
|
|
|
selectDate(wrapper, moment('2016-11-28'), 1); |
|
|
|
expect(wrapper.find('.ant-calendar-picker').getDOMNode()).toBe(document.activeElement); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should focus trigger input after select date in MonthPicker', () => { |
|
|
|
const wrapper = mount(<MonthPicker />); |
|
|
|
const wrapper = mount(<MonthPicker />, { attachTo: document.body }); |
|
|
|
openPanel(wrapper); |
|
|
|
wrapper |
|
|
|
.find('.ant-calendar-month-panel-month') |
|
|
@ -44,46 +46,52 @@ describe('DatePicker', () => { |
|
|
|
.at(6) |
|
|
|
.hasClass('ant-calendar-month-panel-selected-cell'); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).toBe(document.activeElement); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should focus trigger input after select date in WeekPicker', () => { |
|
|
|
const wrapper = mount(<WeekPicker />); |
|
|
|
const wrapper = mount(<WeekPicker />, { attachTo: document.body }); |
|
|
|
openPanel(wrapper); |
|
|
|
selectDate(wrapper, moment('2016-11-23')); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).toBe(document.activeElement); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in DatePicker', () => { |
|
|
|
const wrapper = mount(<DatePicker open />); |
|
|
|
const wrapper = mount(<DatePicker open />, { attachTo: document.body }); |
|
|
|
const wrapperInput = mount(<Input />); |
|
|
|
wrapperInput.instance().select(); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe( |
|
|
|
document.activeElement, |
|
|
|
); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in RangePicker', () => { |
|
|
|
const wrapper = mount(<RangePicker open />); |
|
|
|
const wrapper = mount(<RangePicker open />, { attachTo: document.body }); |
|
|
|
const wrapperInput = mount(<Input />); |
|
|
|
wrapperInput.instance().select(); |
|
|
|
expect(wrapper.find('.ant-calendar-picker').getDOMNode()).not.toBe(document.activeElement); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in WeekPicker', () => { |
|
|
|
const wrapper = mount(<WeekPicker open />); |
|
|
|
const wrapper = mount(<WeekPicker open />, { attachTo: document.body }); |
|
|
|
const wrapperInput = mount(<Input />); |
|
|
|
wrapperInput.instance().select(); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe( |
|
|
|
document.activeElement, |
|
|
|
); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in MonthPicker', () => { |
|
|
|
const wrapper = mount(<MonthPicker open />); |
|
|
|
const wrapper = mount(<MonthPicker open />, { attachTo: document.body }); |
|
|
|
const wrapperInput = mount(<Input />); |
|
|
|
wrapperInput.instance().select(); |
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe( |
|
|
|
document.activeElement, |
|
|
|
); |
|
|
|
wrapper.unmount(); |
|
|
|
}); |
|
|
|
}); |
|
|
|