test(date-picker): add date-picker not auto focus test

pull/14264/head
Yangzhedi 6 years ago committed by 偏右
parent 319949ee1a
commit 41e2103c80

@ -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,
);
});
});

Loading…
Cancel
Save