diff --git a/components/date-picker/WeekPicker.tsx b/components/date-picker/WeekPicker.tsx index bb8c67e1dd..3837394a45 100644 --- a/components/date-picker/WeekPicker.tsx +++ b/components/date-picker/WeekPicker.tsx @@ -55,7 +55,8 @@ class WeekPicker extends React.Component { weekDateRender = (current: any) => { const selectedValue = this.state.value; - const { prefixCls } = this.props; + const { prefixCls, dateRender } = this.props; + const dateNode = dateRender ? dateRender(current) : current.date(); if ( selectedValue && current.year() === selectedValue.year() && @@ -63,11 +64,11 @@ class WeekPicker extends React.Component { ) { return (
-
{current.date()}
+
{dateNode}
); } - return
{current.date()}
; + return
{dateNode}
; }; handleChange = (value: moment.Moment | null) => { @@ -130,8 +131,7 @@ class WeekPicker extends React.Component { suffixIcon, } = this.props; - const { open } = this.state; - const pickerValue = this.state.value; + const { open, value: pickerValue } = this.state; if (pickerValue && localeCode) { pickerValue.locale(localeCode); } diff --git a/components/date-picker/__tests__/WeekPicker.test.js b/components/date-picker/__tests__/WeekPicker.test.js index 63895aafc0..f7b15cc755 100644 --- a/components/date-picker/__tests__/WeekPicker.test.js +++ b/components/date-picker/__tests__/WeekPicker.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mount, render } from 'enzyme'; import DatePicker from '..'; import focusTest from '../../../tests/shared/focusTest'; @@ -12,4 +12,18 @@ describe('WeekPicker', () => { const wrapper = mount(); expect(wrapper.render()).toMatchSnapshot(); }); + + it('should support dateRender', () => { + const wrapper = mount( + {current.format('YYYY-MM-DD')}} />, + ); + expect( + render( + wrapper + .find('Trigger') + .instance() + .getComponent(), + ), + ).toMatchSnapshot(); + }); }); diff --git a/components/date-picker/__tests__/__snapshots__/WeekPicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/WeekPicker.test.js.snap index 7aa25845ae..adf3a4d165 100644 --- a/components/date-picker/__tests__/__snapshots__/WeekPicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/WeekPicker.test.js.snap @@ -1,5 +1,790 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`WeekPicker should support dateRender 1`] = ` +
+ +
+`; + exports[`WeekPicker should support style prop 1`] = `