2017-01-19 13:55:04 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount, render } from 'enzyme';
|
|
|
|
import moment from 'moment';
|
|
|
|
import { RangePicker } from '../';
|
|
|
|
|
|
|
|
describe('RangePicker', () => {
|
|
|
|
it('show month panel according to value', () => {
|
2017-04-01 14:43:36 +08:00
|
|
|
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
|
2017-01-19 13:55:04 +08:00
|
|
|
const wrapper = mount(
|
|
|
|
<RangePicker
|
|
|
|
getCalendarContainer={trigger => trigger}
|
|
|
|
format="YYYY/MM/DD"
|
|
|
|
showTime open
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
wrapper.setProps({ value: [birthday, birthday] });
|
2017-04-02 18:09:23 +08:00
|
|
|
expect(render(wrapper.find('Trigger').node.getComponent()))
|
2017-01-19 13:55:04 +08:00
|
|
|
.toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('switch to corresponding month panel when click presetted ranges', () => {
|
2017-04-01 14:43:36 +08:00
|
|
|
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
|
2017-01-19 13:55:04 +08:00
|
|
|
const wrapper = mount(
|
|
|
|
<RangePicker
|
|
|
|
ranges={{
|
|
|
|
'My Birthday': [birthday, birthday],
|
|
|
|
}}
|
|
|
|
getCalendarContainer={trigger => trigger}
|
|
|
|
format="YYYY/MM/DD"
|
|
|
|
showTime open
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const rangeCalendarWrapper = mount(wrapper.find('Trigger').node.getComponent());
|
|
|
|
rangeCalendarWrapper.find('.ant-calendar-range-quick-selector a')
|
|
|
|
.simulate('click');
|
2017-04-02 18:09:23 +08:00
|
|
|
expect(render(wrapper.find('Trigger').node.getComponent()))
|
2017-01-19 13:55:04 +08:00
|
|
|
.toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|