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

30 lines
668 B
TypeScript
Raw Normal View History

2020-10-29 00:12:25 +08:00
/// <reference types="cypress" />
import { generateHTML } from 'packages/html/src/index'
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: 'doc',
2020-10-29 00:12:25 +08:00
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>')
})
})