/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components/HelpMarkWithDocs/__test__/HelpMarkWithDocs.test.tsx
55 строк
2 KB
Hellen
feat(storage): explain allocation units (#4207)
06 авг 2026, 17:57
Не верифицирован
06 авг 2026, 17:57
514ebd8
Код
Авторство
О чём код?
import React from 'react'; import {ThemeProvider} from '@gravity-ui/uikit'; import {render, screen} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import {HelpMarkWithDocs} from '../HelpMarkWithDocs'; function renderHelpMark(helpMark: React.ReactElement) { return render(<ThemeProvider theme="light">{helpMark}</ThemeProvider>); } describe('HelpMarkWithDocs', () => { test('renders help content without a documentation link', async () => { const user = userEvent.setup(); renderHelpMark(<HelpMarkWithDocs>Allocation units help</HelpMarkWithDocs>); await user.hover(screen.getByRole('button')); expect(await screen.findByText('Allocation units help')).toBeVisible(); expect(screen.queryByRole('link')).not.toBeInTheDocument(); }); test('renders a secure external documentation link', async () => { const user = userEvent.setup(); renderHelpMark( <HelpMarkWithDocs docsLink="https://ydb.tech/docs/concepts/glossary#channel"> Allocation units help </HelpMarkWithDocs>, ); await user.hover(screen.getByRole('button')); const link = await screen.findByRole('link', {name: /Learn more/}); expect(link).toHaveAttribute('href', 'https://ydb.tech/docs/concepts/glossary#channel'); expect(link).toHaveAttribute('target', '_blank'); expect(link).toHaveAttribute('rel', 'noopener noreferrer'); }); test('allows overriding the documentation link title', async () => { const user = userEvent.setup(); renderHelpMark( <HelpMarkWithDocs docsLink="https://ydb.tech/docs/concepts/glossary#channel" docsLinkTitle="Channel documentation" > Allocation units help </HelpMarkWithDocs>, ); await user.hover(screen.getByRole('button')); expect(await screen.findByRole('link', {name: /Channel documentation/})).toBeVisible(); }); });