Skip to content

Commit

Permalink
[fixed] Tooltip accepts a style prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Pleiss and Kenny Wang authored and Geoff Pleiss and Kenny Wang committed Jul 20, 2015
1 parent 91802f6 commit 924f8fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ const Tooltip = React.createClass({
/**
* Title text
*/
title: React.PropTypes.node
title: React.PropTypes.node,
/**
* Style hash
*/
style: React.PropTypes.object
},

getDefaultProps() {
Expand All @@ -60,7 +64,8 @@ const Tooltip = React.createClass({

const style = {
'left': this.props.positionLeft,
'top': this.props.positionTop
'top': this.props.positionTop,
...this.props.style
};

const arrowStyle = {
Expand Down
15 changes: 14 additions & 1 deletion test/TooltipSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ import Tooltip from '../src/Tooltip';
describe('Tooltip', function () {
it('Should output a tooltip with content', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Tooltip>
<Tooltip positionTop={10} positionLeft={20}>
<strong>Tooltip Content</strong>
</Tooltip>
);
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong'));

const tooltip = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'tooltip');
assert.deepEqual(tooltip.props.style, {top: 10, left: 20});
});

describe('When a style property is provided', function () {
it('Should render a tooltip with merged styles', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Tooltip style={{opacity: 0.9}} positionTop={10} positionLeft={20}>
<strong>Tooltip Content</strong>
</Tooltip>
);
const tooltip = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'tooltip');
assert.deepEqual(tooltip.props.style, {opacity: 0.9, top: 10, left: 20});
});
});
});

0 comments on commit 924f8fb

Please sign in to comment.