Skip to content

Commit

Permalink
Test that loading does not trigger a document change
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jul 8, 2022
1 parent 12df66f commit 7817a07
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,27 @@ describe('Markdown serializer from html', () => {
)).toBe(`::: warn\n!warning!\n\n:::`)
})
})

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)
})
})

0 comments on commit 7817a07

Please sign in to comment.