add test case for date picker in tooltip

This commit is contained in:
Eden Wang 2018-07-29 09:40:58 +08:00 committed by 偏右
parent 6804094fa2
commit 84e995ff63

View File

@ -2,6 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';
import Tooltip from '..';
import Button from '../../button';
import DatePicker from '../../date-picker';
describe('Tooltip', () => {
it('check `onVisibleChange` arguments', () => {
@ -174,4 +175,29 @@ describe('Tooltip', () => {
jest.dontMock('rc-trigger', suit);
});
it('should works for date picker', () => {
const onVisibleChange = jest.fn();
const wrapper = mount(
<Tooltip
title=""
mouseEnterDelay={0}
mouseLeaveDelay={0}
onVisibleChange={onVisibleChange}
>
<DatePicker />
</Tooltip>
);
expect(wrapper.find('span.ant-calendar-picker')).toHaveLength(1);
const picker = wrapper.find('span.ant-calendar-picker').at(0);
picker.simulate('mouseenter');
expect(onVisibleChange).toBeCalledWith(true);
expect(wrapper.instance().tooltip.props.visible).toBe(true);
picker.simulate('mouseleave');
expect(onVisibleChange).toBeCalledWith(false);
expect(wrapper.instance().tooltip.props.visible).toBe(false);
});
});