Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<Trigger
popupClassName={overlayClassName}
Expand Down
32 changes: 32 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ const verifyContent = (wrapper, content) => {
};

describe('rc-tooltip', () => {
describe('show when set prop visible', () => {
it('is boolean', () => {
const wrapper = mount(
<Tooltip
visible
overlay={<strong className="x-content">Tooltip content</strong>}
>
<div className="target">Click this</div>
</Tooltip>
);

expect(wrapper.find('.x-content').text()).toBe('Tooltip content');
expect(wrapper.instance().getPopupDomNode()).toBeTruthy();
});

it('is undefined', () => {
const wrapper = mount(
<Tooltip
visible={undefined}
trigger={['click']}
placement="left"
overlay={<strong className="x-content">Tooltip content</strong>}
>
<div className="target">Click this</div>
</Tooltip>
);
wrapper.find('.target').simulate('click');
verifyContent(wrapper, 'Tooltip content');
});
});


describe('shows and hides itself on click', () => {
it('using an element overlay', () => {
const wrapper = mount(
Expand Down