import { describe, it, expect } from 'vitest';
import { renderOfferHtml, renderLegalHtml } from './offer';
describe('renderLegalHtml', () => {
it('renders both language bodies into one standalone document with a switcher', () => {
const html = renderLegalHtml({
ru: { md: '# Политика\n\nрусский текст', title: 'Политика — Эрудит' },
en: { md: '# Policy\n\nenglish text', title: 'Policy — Erudit' },
canonical: 'https://erudit-game.ru/privacy/',
});
expect(html).toContain('');
expect(html).toContain('
Политика — Эрудит'); // Russian is the default
expect(html).toContain('href="https://erudit-game.ru/privacy/"');
// Both bodies are present; English is hidden until toggled.
expect(html).toContain('');
expect(html).toContain('');
expect(html).toContain('Политика
');
expect(html).toContain('Policy
');
// The language + theme switcher and its script.
expect(html).toContain('id="legal-lang"');
expect(html).toContain('id="legal-theme"');
expect(html).toContain('erudit.legal.lang');
// Titles carried on so the toggle can update document.title.
expect(html).toContain('data-title-ru="Политика — Эрудит"');
expect(html).toContain('data-title-en="Policy — Erudit"');
});
it('renders markdown headings, bold clause numbers and lists in both languages', () => {
const html = renderLegalHtml({
ru: { md: '## 2. Предмет\n\n**2.1.** Текст.\n\n- первый\n- второй', title: 't' },
en: { md: '## 2. Subject\n\n**2.1.** Text.', title: 't' },
canonical: 'c',
});
expect(html).toContain('2. Предмет
');
expect(html).toContain('2.1.');
expect(html).toContain('первый');
expect(html).toContain('2. Subject
');
});
it('scopes the shrink-to-fit first-column table rule to the offer only', () => {
// The offer opts into the nowrap product-name column via body.offer; other legal pages (the
// privacy data table) must NOT get it, or their prose first column cannot wrap.
const generic = renderLegalHtml({ ru: { md: '# x', title: 't' }, en: { md: '# x', title: 't' }, canonical: 'c' });
expect(generic).toContain('');
expect(generic).not.toContain(' {
it('is the offer preset: both languages, body.offer, offer title + canonical, EN transliteration', () => {
const html = renderOfferHtml('# Публичная оферта\n\nрусский', '# Public offer\n\nenglish');
expect(html).toContain('');
expect(html).toContain('Публичная оферта — Эрудит');
expect(html).toContain('data-title-en="Public offer — Erudit"');
expect(html).toContain('href="https://erudit-game.ru/offer/"');
expect(html).toContain('Публичная оферта
');
expect(html).toContain('Public offer
');
// The offer page transliterates the Russian product names left in the English (price-list) view.
expect(html).toContain('translitEn');
});
});