mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
parent
bebed2c4ae
commit
70f30ef065
@ -161,7 +161,13 @@ export default class RangePicker extends React.Component<any, RangePickerState>
|
||||
if (typeof value === 'function') {
|
||||
value = value();
|
||||
}
|
||||
|
||||
this.setValue(value, true);
|
||||
|
||||
const { onOk } = this.props;
|
||||
if (onOk) {
|
||||
onOk(value);
|
||||
}
|
||||
}
|
||||
|
||||
setValue(value: RangePickerValue, hidePanel?: boolean) {
|
||||
|
@ -188,4 +188,18 @@ describe('RangePicker', () => {
|
||||
input.simulate('change', { target: { value: dateString } });
|
||||
expect(input.getDOMNode().value).toBe(dateString);
|
||||
});
|
||||
|
||||
it('triggers onOk when click on preset range', () => {
|
||||
const handleOk = jest.fn();
|
||||
const range = [moment().subtract(2, 'd'), moment()];
|
||||
const wrapper = mount(
|
||||
<RangePicker
|
||||
ranges={{ 'recent two days': range }}
|
||||
onOk={handleOk}
|
||||
/>
|
||||
);
|
||||
wrapper.find('.ant-calendar-picker-input').simulate('click');
|
||||
wrapper.find('.ant-calendar-range-quick-selector a').simulate('click');
|
||||
expect(handleOk).toBeCalledWith(range);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user