mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-19 22:07:54 +08:00
30 lines
700 B
TypeScript
30 lines
700 B
TypeScript
|
/// <reference types="cypress" />
|
||
|
|
||
|
import { generateJSON } from 'packages/html/src/index'
|
||
|
import Document from '@tiptap/extension-document'
|
||
|
import Paragraph from '@tiptap/extension-paragraph'
|
||
|
import Text from '@tiptap/extension-text'
|
||
|
|
||
|
describe('generateJSON', () => {
|
||
|
it('generate JSON from HTML without an editor instance', () => {
|
||
|
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',
|
||
|
}],
|
||
|
}],
|
||
|
}))
|
||
|
})
|
||
|
})
|