tiptap/tests/cypress/integration/core/generateHTML.spec.ts

30 lines
662 B
TypeScript
Raw Normal View History

2020-10-29 00:12:25 +08:00
/// <reference types="cypress" />
2020-10-29 00:20:38 +08:00
import { generateHTML } from '@tiptap/html'
2020-10-29 00:12:25 +08:00
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
2020-10-29 00:20:38 +08:00
describe('generateHTML', () => {
2020-10-29 00:12:25 +08:00
it('generate HTML from JSON without an editor instance', () => {
const json = {
type: 'document',
content: [{
type: 'paragraph',
content: [{
type: 'text',
text: 'Example Text',
}],
}],
}
2020-10-29 00:20:38 +08:00
const html = generateHTML(json, [
2020-11-16 16:43:17 +08:00
Document,
Paragraph,
Text,
2020-10-29 00:12:25 +08:00
])
expect(html).to.eq('<p>Example Text</p>')
})
})