Skip to content

Commit 0776637

Browse files
nareshpingalegabrieljablonski
authored andcommitted
chore: adding tests for disableTooltip prop
1 parent cc5d197 commit 0776637

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/test/__snapshots__/tooltip-props.spec.js.snap

+22
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ exports[`tooltip props tooltip with delay show 1`] = `
100100
</div>
101101
`;
102102

103+
exports[`tooltip props tooltip with disableTooltip return false 1`] = `
104+
<div>
105+
<span
106+
data-tooltip-id="example-disableTooltip-false"
107+
>
108+
Lorem Ipsum
109+
</span>
110+
<div
111+
class="react-tooltip react-tooltip__place-top react-tooltip__show"
112+
id="example-disableTooltip-false"
113+
role="tooltip"
114+
style="left: 5px; top: -10px;"
115+
>
116+
Hello World!
117+
<div
118+
class="react-tooltip-arrow"
119+
style="left: -1px; bottom: -4px;"
120+
/>
121+
</div>
122+
</div>
123+
`;
124+
103125
exports[`tooltip props tooltip with float 1`] = `
104126
<div>
105127
<span

src/test/tooltip-props.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,35 @@ describe('tooltip props', () => {
181181
expect(tooltip).toBeInTheDocument()
182182
expect(container).toMatchSnapshot()
183183
})
184+
185+
test('tooltip with disableTooltip return true', async () => {
186+
render(
187+
<TooltipProps
188+
id="example-disableTooltip-true"
189+
content="Hello World!"
190+
disableTooltip={() => true}
191+
/>,
192+
)
193+
const anchorElement = screen.getByText('Lorem Ipsum')
194+
await userEvent.hover(anchorElement)
195+
196+
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument()
197+
})
198+
199+
test('tooltip with disableTooltip return false', async () => {
200+
const { container } = render(
201+
<TooltipProps
202+
id="example-disableTooltip-false"
203+
content="Hello World!"
204+
disableTooltip={() => false}
205+
/>,
206+
)
207+
const anchorElement = screen.getByText('Lorem Ipsum')
208+
await userEvent.hover(anchorElement)
209+
210+
const tooltip = await screen.findByRole('tooltip')
211+
212+
expect(tooltip).toBeInTheDocument()
213+
expect(container).toMatchSnapshot()
214+
})
184215
})

0 commit comments

Comments
 (0)