qazaq-legacy-foundation-web/src/lib/book-project.test.ts
Peppa e60e7ce464
All checks were successful
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 2с
peppa/test test: success за 1с
peppa/build build: success за 50с
ci / checks (pull_request) Successful in 1m38s
deploy / deploy (pull_request) Successful in 18s
QLFW-77: ряд фото книги в «Наших проектах» и фото из админки
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-19 17:16:07 +05:00

38 lines
2.2 KiB
TypeScript

vi.mock('./content', () => ({ loadSettings: vi.fn(async () => null), loadLegal: vi.fn().mockResolvedValue(null), loadContent: vi.fn(async () => ({ home: null, news: [] })) }))
import { describe, expect, it, vi } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import BookProject from '../app/(site)/[locale]/projects/ermek-serkebayev/page'
import { getDict, locales } from '../i18n'
import { bookUrl } from './home-model'
describe('Подтверждённая страница книги', () => {
for (const locale of locales) {
it(`Показывает сведения и сохраняет страницу при смене языка: ${locale}`, async () => {
const html = renderToStaticMarkup(await BookProject({ params: Promise.resolve({ locale }) }))
const t = getDict(locale)
expect(html).toContain(t.book.title)
expect(html).toContain('RUAN')
expect(html).toContain('2026')
expect(html).toContain(bookUrl.replaceAll('&', '&amp;'))
for (const language of locales) expect(html).toContain(`/${language}/projects/ermek-serkebayev`)
expect(html).toContain('cover.jpg')
for (const n of [1, 2, 3, 4]) expect(html).toContain(`photo-${n}.jpg`)
if (locale !== 'ru') expect(html).toContain(t.book.translationReview)
expect(html).not.toContain(t.tbc)
expect(html).not.toMatch(/Организатор|Ұйымдастырушы|organiser/i)
})
}
for (const locale of locales) {
it(`Без пустых разделов, дублей и оплаты: ${locale}`, async () => {
const html = renderToStaticMarkup(await BookProject({ params: Promise.resolve({ locale }) }))
expect(html.match(/<h1[ >]/g)).toHaveLength(1)
expect(html).not.toMatch(/<(p|h2|section|ul)[^>]*><\/(p|h2|section|ul)>/)
expect(html).not.toMatch(/пожертвован|оплат|donat|payment|төлем|қайырмалдық/i)
})
}
it('Неизвестный язык возвращает отсутствующую страницу', async () => {
await expect(BookProject({ params: Promise.resolve({ locale: 'de' }) })).rejects.toThrow('NEXT_HTTP_ERROR_FALLBACK;404')
})
})