From c397ad8c3450fcdfca26ad364f053096e5129720 Mon Sep 17 00:00:00 2001 From: zombieJ Date: Thu, 3 Jan 2019 11:52:31 +0800 Subject: [PATCH] Update rc-calendar to use new lifecycle methods & input auto focus (#14051) close #11848 --- .../__snapshots__/DatePicker.test.js.snap | 1 + .../__snapshots__/WeekPicker.test.js.snap | 1 + .../__snapshots__/other.test.js.snap | 1 + .../date-picker/__tests__/showTime.test.js | 53 +++++++------------ components/date-picker/style/Calendar.less | 1 + .../__snapshots__/index.test.js.snap | 47 ++++++++++++++++ package.json | 2 +- 7 files changed, 71 insertions(+), 35 deletions(-) diff --git a/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap index 8a5efecd5d..732c666931 100644 --- a/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/DatePicker.test.js.snap @@ -115,6 +115,7 @@ exports[`DatePicker prop locale should works 1`] = `
{ , ); - const calendarWrapper = mount( - wrapper - .find('Trigger') - .instance() - .getComponent(), - ); + function findNode(selector) { + return wrapper.find('Trigger').find(selector); + } + expect( - calendarWrapper - .find('.ant-calendar-time-picker-btn') - .hasClass('ant-calendar-time-picker-btn-disabled'), + findNode('.ant-calendar-time-picker-btn').hasClass('ant-calendar-time-picker-btn-disabled'), ).toBe(true); - expect( - calendarWrapper.find('.ant-calendar-ok-btn').hasClass('ant-calendar-ok-btn-disabled'), - ).toBe(true); - calendarWrapper - .find('.ant-calendar-date') + expect(findNode('.ant-calendar-ok-btn').hasClass('ant-calendar-ok-btn-disabled')).toBe(true); + findNode('.ant-calendar-date') .at(10) .simulate('click'); - calendarWrapper - .find('.ant-calendar-date') + findNode('.ant-calendar-date') .at(11) .simulate('click'); + expect( - calendarWrapper - .find('.ant-calendar-time-picker-btn') - .hasClass('ant-calendar-time-picker-btn-disabled'), - ).toBe(false); - expect( - calendarWrapper.find('.ant-calendar-ok-btn').hasClass('ant-calendar-ok-btn-disabled'), + findNode('.ant-calendar-time-picker-btn').hasClass('ant-calendar-time-picker-btn-disabled'), ).toBe(false); + expect(findNode('.ant-calendar-ok-btn').hasClass('ant-calendar-ok-btn-disabled')).toBe(false); expect(onChangeFn).toHaveBeenCalled(); expect(onOpenChangeFn).not.toHaveBeenCalled(); }); - it('hould trigger onOk when press ok button', () => { + it('should trigger onOk when press ok button', () => { const onOkFn = jest.fn(); const onChangeFn = jest.fn(); const onOpenChangeFn = jest.fn(); @@ -147,22 +136,18 @@ describe('RangePicker with showTime', () => { />, ); - const calendarWrapper = mount( - wrapper - .find('Trigger') - .instance() - .getComponent(), - ); - calendarWrapper - .find('.ant-calendar-date') + function findNode(selector) { + return wrapper.find('Trigger').find(selector); + } + + findNode('.ant-calendar-date') .at(10) .simulate('click'); - calendarWrapper - .find('.ant-calendar-date') + findNode('.ant-calendar-date') .at(11) .simulate('click'); onChangeFn.mockClear(); - calendarWrapper.find('.ant-calendar-ok-btn').simulate('click'); + findNode('.ant-calendar-ok-btn').simulate('click'); expect(onOkFn).toHaveBeenCalled(); expect(onOpenChangeFn).toHaveBeenCalledWith(false); expect(onChangeFn).not.toHaveBeenCalled(); diff --git a/components/date-picker/style/Calendar.less b/components/date-picker/style/Calendar.less index 79d3052100..c80b11d0e2 100644 --- a/components/date-picker/style/Calendar.less +++ b/components/date-picker/style/Calendar.less @@ -186,6 +186,7 @@ &-panel { position: relative; + outline: none; } &:hover { diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 75eba7dfe2..8d11412240 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -84,6 +84,7 @@ exports[`Locale Provider set moment locale when locale changes 1`] = `