Skip to content

Commit 47239f3

Browse files
TheSharpieOneeddywashere
authored andcommitted
fix(Tooltip): fix when toggle is not provided (#182)
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.
1 parent 00d08ad commit 47239f3

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/Tooltip.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const defaultProps = {
2929
isOpen: false,
3030
placement: 'bottom',
3131
delay: DEFAULT_DELAYS,
32-
autohide: true
32+
autohide: true,
33+
toggle: function () {}
3334
};
3435

3536
const defaultTetherConfig = {

src/__tests__/Tooltip.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ describe('Tooltip', () => {
176176
wrapper.detach();
177177
});
178178

179+
it('should not throw when props.toggle is not provided ', () => {
180+
const event = jasmine.createSpyObj('event', ['preventDefault']);
181+
182+
const wrapper = mount(
183+
<Tooltip target="target" isOpen={isOpen}>
184+
Tooltip Content
185+
</Tooltip>,
186+
{ attachTo: container }
187+
);
188+
const instance = wrapper.instance();
189+
190+
instance.toggle(event);
191+
192+
wrapper.detach();
193+
});
194+
179195
describe('delay', () => {
180196
it('should accept a number', () => {
181197
isOpen = true;

0 commit comments

Comments
 (0)