Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-07-08 11:56:12 +0300
committerMax <max@nextcloud.com>2022-08-30 12:55:12 +0300
commitcdfcd37e39067fb60b515d306251b0ec24776f70 (patch)
tree5d04ea23d4a10c5669fe649e3a2878041f762126 /src
parentf15ca5d04f692ea8a49b3e93cc26964945d095da (diff)
Test that loading does not trigger a document change
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r--src/tests/markdown.spec.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js
index ca4b26436..2ae3cb4be 100644
--- a/src/tests/markdown.spec.js
+++ b/src/tests/markdown.spec.js
@@ -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)
+ })
+}) \ No newline at end of file