diff --git a/src/Tooltip.jsx b/src/Tooltip.jsx index bada616..9072acf 100644 --- a/src/Tooltip.jsx +++ b/src/Tooltip.jsx @@ -74,11 +74,12 @@ class Tooltip extends Component { placement, align, destroyTooltipOnHide, defaultVisible, getTooltipContainer, + visible, ...restProps, } = this.props; const extraProps = { ...restProps }; - if ('visible' in this.props) { - extraProps.popupVisible = this.props.visible; + if (typeof visible !== 'undefined') { + extraProps.popupVisible = visible; } return ( { }; describe('rc-tooltip', () => { + describe('show when set prop visible', () => { + it('is boolean', () => { + const wrapper = mount( + Tooltip content} + > +
Click this
+
+ ); + + expect(wrapper.find('.x-content').text()).toBe('Tooltip content'); + expect(wrapper.instance().getPopupDomNode()).toBeTruthy(); + }); + + it('is undefined', () => { + const wrapper = mount( + Tooltip content} + > +
Click this
+
+ ); + wrapper.find('.target').simulate('click'); + verifyContent(wrapper, 'Tooltip content'); + }); + }); + + describe('shows and hides itself on click', () => { it('using an element overlay', () => { const wrapper = mount(