import { renderToStaticMarkup } from 'react-dom/server' import { describe, expect, it } from 'vitest' import SidesBlock, { passageLink, type Passage } from './SidesBlock' // Test-only wording: nothing here is served by the app. const p = (quote: string, extra: Partial = {}): Passage => ({ quote, jurisdictionName: 'Testville', ...extra }) describe('SidesBlock', () => { it('renders nothing without sides, or when either side is empty', () => { expect(renderToStaticMarkup()).toBe('') expect(renderToStaticMarkup()).toBe('') expect(renderToStaticMarkup()).toBe('') }) it('shows both columns with the quote, its source and a timestamped link', () => { const html = renderToStaticMarkup( , ) expect(html).toContain('What was said for') expect(html).toContain('What was said against') expect(html).toContain('quote-for') expect(html).toContain('Resident') expect(html).toContain('t=95s') expect(html).not.toContain('undefined') }) it('caps each side at two quotes with a control for the rest', () => { const many = [p('q1'), p('q2'), p('q3')] const html = renderToStaticMarkup() expect(html).toContain('q2') expect(html).not.toContain('q3') expect(html).toContain('Show 1 more') }) it('adds a start time only when it is known', () => { expect(passageLink(p('q', { videoUrl: 'https://example.test/v' }))).toBe('https://example.test/v') expect(passageLink(p('q'))).toBeNull() }) })