All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
38 lines
2.2 KiB
TypeScript
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('&', '&'))
|
|
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')
|
|
})
|
|
})
|