2021-05-06 03:24:24 +08:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
import { generateJSON } from '@tiptap/core'
|
|
|
|
import Document from '@tiptap/extension-document'
|
|
|
|
import Paragraph from '@tiptap/extension-paragraph'
|
|
|
|
import Text from '@tiptap/extension-text'
|
|
|
|
|
|
|
|
describe('generateJSON', () => {
|
2021-05-06 03:33:39 +08:00
|
|
|
it('generate JSON from HTML without an editor instance', () => {
|
2021-05-06 03:24:24 +08:00
|
|
|
const html = '<p>Example Text</p>'
|
|
|
|
|
|
|
|
const json = generateJSON(html, [
|
|
|
|
Document,
|
|
|
|
Paragraph,
|
|
|
|
Text,
|
|
|
|
])
|
|
|
|
|
|
|
|
expect(JSON.stringify(json)).to.eq(JSON.stringify({
|
|
|
|
type: 'doc',
|
|
|
|
content: [{
|
|
|
|
type: 'paragraph',
|
|
|
|
content: [{
|
|
|
|
type: 'text',
|
|
|
|
text: 'Example Text',
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
})
|