From 0f4ccc6b9831edd31ca6380cf4e5f70e8278f7f6 Mon Sep 17 00:00:00 2001 From: devdammit Date: Mon, 25 Dec 2017 21:54:48 +0300 Subject: [PATCH 1/2] added check prop 'visible' on undefined --- src/Tooltip.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tooltip.jsx b/src/Tooltip.jsx index bada616..513dec2 100644 --- a/src/Tooltip.jsx +++ b/src/Tooltip.jsx @@ -77,7 +77,7 @@ class Tooltip extends Component { ...restProps, } = this.props; const extraProps = { ...restProps }; - if ('visible' in this.props) { + if (typeof this.props.visible !== 'undefined') { extraProps.popupVisible = this.props.visible; } return ( Date: Sun, 31 Dec 2017 11:33:37 +0300 Subject: [PATCH 2/2] Added tests for prop 'visible' --- src/Tooltip.jsx | 5 +++-- tests/index.test.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Tooltip.jsx b/src/Tooltip.jsx index 513dec2..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 (typeof this.props.visible !== 'undefined') { - 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(