From f01d436dd5709278239d8cd1ff6a3c5f752c381c Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Thu, 2 Aug 2018 11:22:32 +0800 Subject: [PATCH] add test case for input.group in tooltip --- components/tooltip/__tests__/tooltip.test.js | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/tooltip/__tests__/tooltip.test.js b/components/tooltip/__tests__/tooltip.test.js index ae7ab7b624..58590e5a48 100644 --- a/components/tooltip/__tests__/tooltip.test.js +++ b/components/tooltip/__tests__/tooltip.test.js @@ -3,6 +3,8 @@ import { mount } from 'enzyme'; import Tooltip from '..'; import Button from '../../button'; import DatePicker from '../../date-picker'; +import Input from '../../input'; +import Group from '../../input/Group'; const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); @@ -202,4 +204,32 @@ describe('Tooltip', () => { expect(onVisibleChange).toBeCalledWith(false); expect(wrapper.instance().tooltip.props.visible).toBe(false); }); + + it('should works for input group', async () => { + const onVisibleChange = jest.fn(); + + const wrapper = mount( + + + + + + + ); + + expect(wrapper.find('Group')).toHaveLength(1); + const picker = wrapper.find('Group').at(0); + picker.simulate('mouseenter'); + await delay(100); + expect(onVisibleChange).toBeCalledWith(true); + expect(wrapper.instance().tooltip.props.visible).toBe(true); + + picker.simulate('mouseleave'); + await delay(100); + expect(onVisibleChange).toBeCalledWith(false); + expect(wrapper.instance().tooltip.props.visible).toBe(false); + }); });