Skip to content

Commit

Permalink
fix(Tooltip): fix when toggle is not provided (#182)
Browse files Browse the repository at this point in the history
Before, when props.toggle was not provided, this.toggle would throw
Essentially when someone just provides the `isOpen` prop and wants
to manaully control the hiding/showing.
  • Loading branch information
TheSharpieOne authored and eddywashere committed Oct 18, 2016
1 parent 00d08ad commit 47239f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const defaultProps = {
isOpen: false,
placement: 'bottom',
delay: DEFAULT_DELAYS,
autohide: true
autohide: true,
toggle: function () {}
};

const defaultTetherConfig = {
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/Tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ describe('Tooltip', () => {
wrapper.detach();
});

it('should not throw when props.toggle is not provided ', () => {
const event = jasmine.createSpyObj('event', ['preventDefault']);

const wrapper = mount(
<Tooltip target="target" isOpen={isOpen}>
Tooltip Content
</Tooltip>,
{ attachTo: container }
);
const instance = wrapper.instance();

instance.toggle(event);

wrapper.detach();
});

describe('delay', () => {
it('should accept a number', () => {
isOpen = true;
Expand Down

0 comments on commit 47239f3

Please sign in to comment.