qazaq-legacy-foundation-web/src/components/book-link.test.ts

21 lines
953 B
TypeScript

import { createElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { getDict } from '@/i18n'
import { bookUrl } from '@/lib/home-model'
import { BookLink } from './BookLink'
describe('Сценарий: пояснение получения книги', () => {
it.each(['ru', 'kk', 'en'] as const)('ссылка и пояснение на языке %s', (locale) => {
const t = getDict(locale).book
const html = renderToStaticMarkup(createElement(BookLink, { url: bookUrl, t }))
expect(html).toContain(bookUrl.replaceAll('&', '&'))
expect(html).toContain(t.get)
expect(html).toContain(t.getNote)
expect(html).toContain('Flip')
})
it.each([null, '', ' '])('нет адреса книги: %s — блок скрыт', (url) => {
expect(renderToStaticMarkup(createElement(BookLink, { url, t: getDict('ru').book }))).toBe('')
})
})