|
|
|
@ -3,6 +3,7 @@ import { mount } from 'enzyme';
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
import MockDate from 'mockdate';
|
|
|
|
|
import DatePicker from '..';
|
|
|
|
|
import Input from '../../input';
|
|
|
|
|
import { selectDate, openPanel } from './utils';
|
|
|
|
|
|
|
|
|
|
const { MonthPicker, WeekPicker, RangePicker } = DatePicker;
|
|
|
|
@ -51,4 +52,38 @@ describe('DatePicker', () => {
|
|
|
|
|
selectDate(wrapper, moment('2016-11-23'));
|
|
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).toBe(document.activeElement);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in DatePicker', () => {
|
|
|
|
|
const wrapper = mount(<DatePicker open />);
|
|
|
|
|
const wrapperInput = mount(<Input />);
|
|
|
|
|
wrapperInput.instance().select();
|
|
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe(
|
|
|
|
|
document.activeElement,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in RangePicker', () => {
|
|
|
|
|
const wrapper = mount(<RangePicker open />);
|
|
|
|
|
const wrapperInput = mount(<Input />);
|
|
|
|
|
wrapperInput.instance().select();
|
|
|
|
|
expect(wrapper.find('.ant-calendar-picker').getDOMNode()).not.toBe(document.activeElement);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in WeekPicker', () => {
|
|
|
|
|
const wrapper = mount(<WeekPicker open />);
|
|
|
|
|
const wrapperInput = mount(<Input />);
|
|
|
|
|
wrapperInput.instance().select();
|
|
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe(
|
|
|
|
|
document.activeElement,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not auto focus trigger input when open prop is true in MonthPicker', () => {
|
|
|
|
|
const wrapper = mount(<MonthPicker open />);
|
|
|
|
|
const wrapperInput = mount(<Input />);
|
|
|
|
|
wrapperInput.instance().select();
|
|
|
|
|
expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe(
|
|
|
|
|
document.activeElement,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|