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-10-29 00:12:25 +08:00
|
|
|
Document(),
|
|
|
|
Paragraph(),
|
|
|
|
Text(),
|
|
|
|
])
|
|
|
|
|
|
|
|
expect(html).to.eq('<p>Example Text</p>')
|
|
|
|
})
|
|
|
|
})
|