2020-10-29 00:12:25 +08:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
2021-05-06 05:14:57 +08:00
|
|
|
import { generateHTML } from '@tiptap/core'
|
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 = {
|
2021-01-28 18:58:10 +08:00
|
|
|
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>')
|
|
|
|
})
|
|
|
|
})
|