Skip to content

Commit

Permalink
test textWithTooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Lysak committed Dec 3, 2024
1 parent e3d028e commit a8f7dfe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/components/@atoms/TextWithTooltip/TextWithTooltip.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { render, screen, userEvent } from '@app/test-utils'

import { describe, expect, it } from 'vitest'

import { TextWithTooltip } from './TextWithTooltip'

describe('TextWithTooltip', () => {
it('should render tooltip', async () => {
render(<TextWithTooltip tooltipContent="tooltip-content" />)

const element = screen.getByTestId('tooltip')
await userEvent.hover(element)
expect(screen.getByText('tooltip-content')).toBeInTheDocument()
})

it('should render tooltip with link', async () => {
render(<TextWithTooltip tooltipContent="tooltip-content" link="https://link.com" />)

const element = screen.getByTestId('tooltip')
await userEvent.hover(element)
expect(screen.getByText('tooltip-content')).toBeInTheDocument()
expect(screen.getByRole('link')).toHaveAttribute('href', 'https://link.com')
})
})
2 changes: 1 addition & 1 deletion src/components/@atoms/TextWithTooltip/TextWithTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TextWithTooltip = ({
}
background="indigoSurface"
>
<Container>
<Container data-testid="tooltip">
<Typography fontVariant="smallBold" color="indigo">
{children}
</Typography>
Expand Down

0 comments on commit a8f7dfe

Please sign in to comment.