From 7817a077e915c438f5728986f7d091b71d24003b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 8 Jul 2022 10:56:12 +0200 Subject: [PATCH] Test that loading does not trigger a document change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/tests/markdown.spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 8d5f51f5844..407c183ae4a 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -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) + }) +}) \ No newline at end of file