Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Test that loading does not trigger a document change
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and max-nextcloud committed Aug 30, 2022
commit cdfcd37e39067fb60b515d306251b0ec24776f70
24 changes: 24 additions & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,27 @@ describe('Markdown serializer from html', () => {
expect(markdownThroughEditorHtml('<pre id="frontmatter"><code>---</code></pre><h1>Heading</h1>')).toBe('----\n---\n----\n\n# Heading')
})
})

describe('Trailing nodes', () => {
test('No extra transaction is added after loading', () => {
const source = "# My heading\n\n* test\n* test2"
const tiptap = createEditor({
content: markdownit.render(source),
enableRichEditing: true,
})

const jsonBefore = tiptap.getJSON()

// Focus triggers a transaction which is adding the trailing node
// this pushes a step through the collaboration plugin
// Resulting markdown will not contain the trailing paragraph so everytime the tiptap instance is created from the html, this transaction gets dispatched
tiptap.commands.focus()

const jsonAfter = tiptap.getJSON()
expect(jsonAfter).toStrictEqual(jsonBefore)

const serializer = createMarkdownSerializer(tiptap.schema)
const md = serializer.serialize(tiptap.state.doc)
expect(md).toBe(source)
})
})