From a8f7dfe20649c3c2a325154dbf40d381d4e8eb7b Mon Sep 17 00:00:00 2001 From: Stanislav Lysak Date: Tue, 3 Dec 2024 10:29:50 +0200 Subject: [PATCH] test textWithTooltip --- .../TextWithTooltip/TextWithTooltip.test.tsx | 24 +++++++++++++++++++ .../TextWithTooltip/TextWithTooltip.tsx | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/components/@atoms/TextWithTooltip/TextWithTooltip.test.tsx diff --git a/src/components/@atoms/TextWithTooltip/TextWithTooltip.test.tsx b/src/components/@atoms/TextWithTooltip/TextWithTooltip.test.tsx new file mode 100644 index 000000000..3539227b5 --- /dev/null +++ b/src/components/@atoms/TextWithTooltip/TextWithTooltip.test.tsx @@ -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() + + const element = screen.getByTestId('tooltip') + await userEvent.hover(element) + expect(screen.getByText('tooltip-content')).toBeInTheDocument() + }) + + it('should render tooltip with link', async () => { + render() + + const element = screen.getByTestId('tooltip') + await userEvent.hover(element) + expect(screen.getByText('tooltip-content')).toBeInTheDocument() + expect(screen.getByRole('link')).toHaveAttribute('href', 'https://link.com') + }) +}) diff --git a/src/components/@atoms/TextWithTooltip/TextWithTooltip.tsx b/src/components/@atoms/TextWithTooltip/TextWithTooltip.tsx index ab9240428..dea24645e 100644 --- a/src/components/@atoms/TextWithTooltip/TextWithTooltip.tsx +++ b/src/components/@atoms/TextWithTooltip/TextWithTooltip.tsx @@ -63,7 +63,7 @@ export const TextWithTooltip = ({ } background="indigoSurface" > - + {children}