提交 19dc14af 编写于 作者: Z zy410419243

refactor: abstract common method for comparison

上级 cfe531a5
...@@ -176,11 +176,8 @@ describe('Calendar', () => { ...@@ -176,11 +176,8 @@ describe('Calendar', () => {
expect(onPanelChange).toBeCalled(); expect(onPanelChange).toBeCalled();
expect(onPanelChange.mock.calls[0][1]).toEqual('year'); expect(onPanelChange.mock.calls[0][1]).toEqual('year');
}); });
it('if value.month > end.month, value.month -> end.month', () => {
const value = new Moment('1990-01-03'); const createWrapper = (start, end, value, onValueChange) => {
const start = new Moment('2019-01-01');
const end = new Moment('2019-03-01');
const onValueChange = jest.fn();
const wrapper = mount( const wrapper = mount(
<Header <Header
onValueChange={onValueChange} onValueChange={onValueChange}
...@@ -197,7 +194,15 @@ describe('Calendar', () => { ...@@ -197,7 +194,15 @@ describe('Calendar', () => {
.find('.ant-select-dropdown-menu-item') .find('.ant-select-dropdown-menu-item')
.at(0) .at(0)
.simulate('click'); .simulate('click');
expect(onValueChange).toHaveBeenCalledWith(value.year('2019')); };
it('if value.month > end.month, value.month -> end.month', () => {
const value = new Moment('1990-01-03');
const start = new Moment('2019-04-01');
const end = new Moment('2019-11-01');
const onValueChange = jest.fn();
createWrapper(start, end, value, onValueChange);
expect(onValueChange).toHaveBeenCalledWith(value.year('2019').month('3'));
}); });
it('if start.month > value.month, value.month -> start.month ', () => { it('if start.month > value.month, value.month -> start.month ', () => {
...@@ -205,22 +210,7 @@ describe('Calendar', () => { ...@@ -205,22 +210,7 @@ describe('Calendar', () => {
const start = new Moment('2019-11-01'); const start = new Moment('2019-11-01');
const end = new Moment('2019-03-01'); const end = new Moment('2019-03-01');
const onValueChange = jest.fn(); const onValueChange = jest.fn();
const wrapper = mount( createWrapper(start, end, value, onValueChange);
<Header
onValueChange={onValueChange}
value={value}
validRange={[start, end]}
locale={{ year: '' }}
/>,
);
wrapper
.find('.ant-fullcalendar-year-select')
.hostNodes()
.simulate('click');
wrapper
.find('.ant-select-dropdown-menu-item')
.at(0)
.simulate('click');
expect(onValueChange).toHaveBeenCalledWith(value.year('2019').month('10')); expect(onValueChange).toHaveBeenCalledWith(value.year('2019').month('10'));
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册