mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
Add test case for Tooltip and Icon
This commit is contained in:
parent
3cbb5da6c2
commit
54a1534a3d
@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { render } from 'enzyme';
|
||||
import { render, mount } from 'enzyme';
|
||||
import Icon from '..';
|
||||
import ReactIcon from '@ant-design/icons-react';
|
||||
import Tooltip from '../../tooltip';
|
||||
import { getThemeFromTypeName, withThemeSuffix } from '../utils';
|
||||
|
||||
describe('Icon', () => {
|
||||
@ -72,6 +73,29 @@ describe('Icon', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should support wrapped by Tooltip', () => {
|
||||
const onVisibleChange = jest.fn();
|
||||
const wrapper = mount(
|
||||
<Tooltip
|
||||
title="xxxxx"
|
||||
mouseEnterDelay={0}
|
||||
mouseLeaveDelay={0}
|
||||
onVisibleChange={onVisibleChange}
|
||||
>
|
||||
<Icon type="home" />
|
||||
</Tooltip>
|
||||
);
|
||||
expect(wrapper.find('i')).toHaveLength(1);
|
||||
const icon = wrapper.find('i').at(0);
|
||||
icon.simulate('mouseenter');
|
||||
expect(onVisibleChange).toBeCalledWith(true);
|
||||
expect(wrapper.instance().tooltip.props.visible).toBe(true);
|
||||
|
||||
icon.simulate('mouseleave');
|
||||
expect(onVisibleChange).toBeCalledWith(false);
|
||||
expect(wrapper.instance().tooltip.props.visible).toBe(false);
|
||||
});
|
||||
|
||||
describe('`component` prop', () => {
|
||||
it('can access to svg defs if has children', () => {
|
||||
const wrapper = render(
|
||||
|
Loading…
Reference in New Issue
Block a user