diff --git a/components/date-picker/__tests__/focus.test.js b/components/date-picker/__tests__/focus.test.js index 6db27d4c9c..e02358ffec 100644 --- a/components/date-picker/__tests__/focus.test.js +++ b/components/date-picker/__tests__/focus.test.js @@ -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(); + const wrapperInput = mount(); + 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(); + const wrapperInput = mount(); + 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(); + const wrapperInput = mount(); + 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(); + const wrapperInput = mount(); + wrapperInput.instance().select(); + expect(wrapper.find('.ant-calendar-picker-input').getDOMNode()).not.toBe( + document.activeElement, + ); + }); });