From 41e2103c80320524bf3eabee1e0f8962ec854ae5 Mon Sep 17 00:00:00 2001 From: Yangzhedi Date: Tue, 8 Jan 2019 20:50:02 +0800 Subject: [PATCH] test(date-picker): add date-picker not auto focus test --- .../date-picker/__tests__/focus.test.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) 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, + ); + }); });