import {describe, it, expect} from 'vitest' import {Editor} from '@tiptap/core' import StarterKit from '@tiptap/starter-kit' import {BlockquoteWithCommentId} from './blockquoteWithCommentId' describe('BlockquoteWithCommentId extension', () => { const createEditor = (content: string = '') => { return new Editor({ extensions: [ StarterKit.configure({blockquote: false}), BlockquoteWithCommentId, ], content, }) } it('preserves data-comment-id through setContent → getHTML round-trip', () => { const editor = createEditor('

hi

') const html = editor.getHTML() expect(html).toContain('data-comment-id="42"') editor.destroy() }) it('renders a plain blockquote (no attribute) unchanged', () => { const editor = createEditor('

just a quote

') const html = editor.getHTML() expect(html).toContain('
') expect(html).not.toContain('data-comment-id') editor.destroy() }) it('preserves nested rich content inside the blockquote', () => { const editor = createEditor( '

this is bold text

', ) const html = editor.getHTML() expect(html).toContain('data-comment-id="7"') expect(html).toContain('bold') editor.destroy() }) it('drops a malformed data-comment-id (non-integer)', () => { const editor = createEditor('

x

') const html = editor.getHTML() expect(html).not.toContain('data-comment-id') editor.destroy() }) it('drops a non-positive data-comment-id', () => { const editor = createEditor('

x

') const html = editor.getHTML() expect(html).not.toContain('data-comment-id') editor.destroy() }) })