// @vitest-environment jsdom /** * What the RichText page claims, pinned: every block draws as its element; text * is text, never HTML; links are found in text and never in code, and a click * on one stays on it; an unknown block keeps its words; a table's first row of * header cells is its header; the app's own parts go where the page says. */ import { afterEach, describe, expect, it, vi } from 'vitest' import { cleanup, fireEvent, render, screen } from '@testing-library/react' import { RichText, richTextClassName, type RichTextBlock, type RichTextRun } from './RichText' afterEach(cleanup) const t = (text: string, ...marks: string[]): RichTextRun => ({ text, marks }) const p = (...inline: RichTextRun[]): RichTextBlock => ({ type: 'paragraph', inline }) const cell = (typeName: string, text: string): RichTextBlock => ({ type: 'unknown', typeName, children: [p(t(text))] }) const row = (typeName: string, ...texts: string[]): RichTextBlock => ({ type: 'unknown', typeName: 'tableRow', children: texts.map((x) => cell(typeName, x)) }) const draw = (blocks: RichTextBlock[], props = {}) => render().container describe('RichText', () => { it('draws renderAfter after a line of words, inside a list item, and nowhere it returns nothing', () => { const after = (block: RichTextBlock) => (block.id === 'skip' ? null :