Skip to content

Commit

Permalink
add to test for the open tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Mar 15, 2023
1 parent 2991cd9 commit 04e898c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Components/Buttons.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import {fireEvent, render} from '@testing-library/react'
import {fireEvent, render, renderHook, act} from '@testing-library/react'
import {MockComponent} from '../__mocks__/MockComponent'
import {TooltipIconButton} from './Buttons'
import useStore from '../store/useStore'
import QuestionIcon from '../assets/icons/Question.svg'


Expand All @@ -25,4 +26,20 @@ describe('<TooltipIconButton />', () => {
const tooltip = await rendered.findByRole('tooltip')
expect(tooltip).toBeInTheDocument()
})
test('show tooltip when the help is activated', async () => {
const {result} = renderHook(() => useStore((state) => state))
await act(() => {
result.current.toggleIsTooltipsOpen()
})
const {getByText} = render(
<MockComponent>
<TooltipIconButton
title={'TestTooltip'}
// eslint-disable-next-line no-empty-function
onClick={() => {}}
icon={<QuestionIcon/>}
/>
</MockComponent>)
expect(await getByText('TestTooltip')).toBeVisible()
})
})

0 comments on commit 04e898c

Please sign in to comment.