fix doc error and add test case for WeekPicker

This commit is contained in:
HarlanLuo 2018-12-24 17:37:19 +08:00 committed by 偏右
parent a7bedca0e2
commit 41aa37bd99
3 changed files with 36 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';
import DatePicker from '..';
import focusTest from '../../../tests/shared/focusTest';
import { openPanel } from './utils';
const { WeekPicker } = DatePicker;
@ -12,4 +13,39 @@ describe('WeekPicker', () => {
const wrapper = mount(<WeekPicker style={{ width: 400 }} />);
expect(wrapper.render()).toMatchSnapshot();
});
it('extra footer works', () => {
const wrapper = mount(
<WeekPicker renderExtraFooter={mode => <span className="extra-node">{mode}</span>} />,
);
openPanel(wrapper);
let extraNode = wrapper.find('.extra-node');
expect(extraNode.length).toBe(1);
expect(extraNode.text()).toBe('date');
wrapper
.find('.ant-calendar-month-select')
.hostNodes()
.simulate('click');
extraNode = wrapper.find('.ant-calendar-month-panel .extra-node');
expect(extraNode.length).toBe(1);
expect(extraNode.text()).toBe('month');
wrapper
.find('.ant-calendar-year-select')
.hostNodes()
.simulate('click');
extraNode = wrapper.find('.ant-calendar-year-panel .extra-node');
expect(extraNode.length).toBe(1);
expect(extraNode.text()).toBe('year');
wrapper
.find('.ant-calendar-year-panel-decade-select')
.hostNodes()
.simulate('click');
extraNode = wrapper.find('.ant-calendar-decade-panel .extra-node');
expect(extraNode.length).toBe(1);
expect(extraNode.text()).toBe('decade');
});
});

View File

@ -65,7 +65,6 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
| style | to customize the style of the input box | object | {} |
| onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - |
| onPanelChange | callback when picker panel mode is changed | function(value, mode) | - |
| renderFooter | renderer of picker panel footer | (mode) => ReactNode | - |
### Common Methods

View File

@ -66,7 +66,6 @@ moment.locale('zh-cn');
| style | 自定义输入框样式 | object | {} |
| onOpenChange | 弹出日历和关闭日历的回调 | function(status) | 无 |
| onPanelChange | 日历面板切换的回调 | function(value, mode) | - |
| renderFooter | 渲染弹出层的页脚 | (mode) => ReactNode | - |
### 共同的方法