diff --git a/src/components/Tooltip.js b/src/components/Tooltip.js
new file mode 100644
index 000000000..b173b3ca3
--- /dev/null
+++ b/src/components/Tooltip.js
@@ -0,0 +1,28 @@
+import React from 'react';
+import { Tooltip as InnerTooltip } from 'reactstrap';
+
+export default class Tooltip extends React.Component {
+ static propTypes = {
+ isOpen: React.PropTypes.bool
+ };
+
+ static defaultProps = {
+ isOpen: false
+ };
+
+ state = {
+ isOpen: this.props.isOpen
+ };
+
+ toggle = () => this.setState({
+ isOpen: !this.state.isOpen
+ });
+
+ render() {
+ const { isOpen, ...props } = this.props;
+
+ return (
+
+ );
+ }
+}
diff --git a/src/index.js b/src/index.js
index 4f2fdef93..3629fd0d5 100755
--- a/src/index.js
+++ b/src/index.js
@@ -59,8 +59,7 @@ import {
Row,
TabContent,
TabPane,
- TetherContent,
- Tooltip
+ TetherContent
} from 'reactstrap';
// Gears:
@@ -86,6 +85,7 @@ import Steps from './components/Steps.js';
import SummaryBox from './components/SummaryBox.js';
import SummaryBoxItem from './components/SummaryBoxItem.js';
import Table from './components/Table.js';
+import Tooltip from './components/Tooltip.js';
export {
// reactstrap
@@ -152,7 +152,6 @@ export {
TabPane,
Table,
TetherContent,
- Tooltip,
Select,
@@ -175,5 +174,6 @@ export {
Spinner,
Steps,
SummaryBox,
- SummaryBoxItem
+ SummaryBoxItem,
+ Tooltip
};
diff --git a/stories/Tooltip.js b/stories/Tooltip.js
index 5e7932949..f8164893b 100644
--- a/stories/Tooltip.js
+++ b/stories/Tooltip.js
@@ -3,43 +3,18 @@ import { Tooltip } from '../src';
import { storiesOf } from '@kadira/storybook';
import { select } from '@kadira/storybook-addon-knobs';
-export default class TooltipExample extends React.Component {
- static displayName = 'Tooltip';
-
- state = {
- tooltipOpen: false
- };
-
- toggle = () => this.setState({
- tooltipOpen: !this.state.tooltipOpen
- });
-
- render() {
- return (
-
- {this.props.children}
-
- );
- }
-}
-
storiesOf('Tooltip', module)
.addWithInfo('Live example', () => (
Somewhere in here is a tooltip.
-
Hello world!
-
+
)
);
diff --git a/test/components/Tooltip.spec.js b/test/components/Tooltip.spec.js
new file mode 100644
index 000000000..0f2881665
--- /dev/null
+++ b/test/components/Tooltip.spec.js
@@ -0,0 +1,36 @@
+/* eslint-env mocha */
+import React from 'react';
+import assert from 'assert';
+import { shallow } from 'enzyme';
+
+import Tooltip from '../../src/components/Tooltip';
+
+describe('', () => {
+ describe('by default', () => {
+ const component = shallow();
+
+ it('should be closed', () => {
+ assert.equal(component.prop('isOpen'), false);
+ assert.equal(component.state('isOpen'), false);
+ });
+
+ it('should forward props', () => {
+ assert.equal(component.prop('placement'), 'right');
+ });
+
+ it('should toggle state', () => {
+ component.prop('toggle')();
+ assert.equal(component.prop('isOpen'), true);
+ assert.equal(component.state('isOpen'), true);
+ });
+ });
+
+ describe('with initial props', () => {
+ const component = shallow();
+
+ it('should seed state', () => {
+ assert.equal(component.prop('isOpen'), true);
+ assert.equal(component.state('isOpen'), true);
+ });
+ });
+});