import { describe, expect, it } from 'vitest' import { renderMarkdownNodeToHtml, renderNestedMarkdownToHtml, } from '../packages/markstream-vue2/src/utils/nestedHtml' describe('vue2 nested html helper', () => { it('renders nested custom nodes and markdown children into stable html', () => { const html = renderNestedMarkdownToHtml( { nodes: [ { type: 'paragraph', raw: '', children: [ { type: 'text', raw: '', content: 'Before' }, ], }, { type: 'thinking', tag: 'thinking', raw: '', attrs: [['class', 'preset']], children: [ { type: 'paragraph', raw: '', children: [ { type: 'text', raw: '', content: 'Inner ' }, { type: 'strong', raw: '', children: [ { type: 'text', raw: '', content: 'bold' }, ], }, ], }, { type: 'list', raw: '', ordered: false, items: [ { type: 'list_item', raw: '', children: [ { type: 'text', raw: '', content: 'item' }, ], }, ], }, ], }, ], }, { customHtmlTags: ['thinking'], customNodeClass(node) { return node.type === 'thinking' ? 'thinking-node__nested' : '' }, }, ) expect(html).toContain('

Before

') expect(html).toContain('bold') expect(html).toContain('') expect(html).toContain('data-markstream-custom-tag="thinking"') expect(html).toContain('class="markstream-nested-custom markstream-nested-custom--thinking thinking-node__nested preset"') }) it('falls back to markdown rendering for streaming content fragments', () => { const html = renderNestedMarkdownToHtml( { node: { type: 'thinking', tag: 'thinking', raw: '', content: 'Streamed intro\n\n- first\n- second', } as any, }, { cacheKey: 'vue2-nested-html-streaming', customHtmlTags: ['thinking'], }, ) expect(html).toContain('

Streamed intro

') expect(html).toContain('