Skip to content

Commit

Permalink
chore: adding tests for disableTooltip prop
Browse files Browse the repository at this point in the history
  • Loading branch information
nareshpingale committed Jul 23, 2024
1 parent 30e2356 commit 263138a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/__snapshots__/tooltip-props.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ exports[`tooltip props tooltip with delay show 1`] = `
</div>
`;

exports[`tooltip props tooltip with disableTooltip return false 1`] = `
<div>
<span
data-tooltip-id="example-disableTooltip-false"
>
Lorem Ipsum
</span>
<div
class="react-tooltip react-tooltip__place-top react-tooltip__show"
id="example-disableTooltip-false"
role="tooltip"
style="left: 5px; top: -10px;"
>
Hello World!
<div
class="react-tooltip-arrow"
style="left: -1px; bottom: -4px;"
/>
</div>
</div>
`;

exports[`tooltip props tooltip with float 1`] = `
<div>
<span
Expand Down
31 changes: 31 additions & 0 deletions src/test/tooltip-props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,35 @@ describe('tooltip props', () => {
expect(tooltip).toBeInTheDocument()
expect(container).toMatchSnapshot()
})

test('tooltip with disableTooltip return true', async () => {
render(
<TooltipProps
id="example-disableTooltip-true"
content="Hello World!"
disableTooltip={() => true}
/>,
)
const anchorElement = screen.getByText('Lorem Ipsum')
await userEvent.hover(anchorElement)

expect(screen.queryByRole('tooltip')).not.toBeInTheDocument()
})

test('tooltip with disableTooltip return false', async () => {
const { container } = render(
<TooltipProps
id="example-disableTooltip-false"
content="Hello World!"
disableTooltip={() => false}
/>,
)
const anchorElement = screen.getByText('Lorem Ipsum')
await userEvent.hover(anchorElement)

const tooltip = await screen.findByRole('tooltip')

expect(tooltip).toBeInTheDocument()
expect(container).toMatchSnapshot()
})
})

0 comments on commit 263138a

Please sign in to comment.