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
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/tables.spec.js')
-rw-r--r--src/tests/tables.spec.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/tables.spec.js b/src/tests/tables.spec.js
new file mode 100644
index 000000000..7a347eb9e
--- /dev/null
+++ b/src/tests/tables.spec.js
@@ -0,0 +1,36 @@
+import { createEditor } from './../EditorFactory'
+import { createMarkdownSerializer } from './../extensions/Markdown'
+import markdownit from './../markdownit'
+import input from './fixtures/table.md'
+import output from './fixtures/table.html'
+import otherStructure from './fixtures/tableWithOtherStructure.html'
+
+describe('Table', () => {
+
+ test('load into editor', () => {
+ const tiptap = editorWithContent(markdownit.render(input))
+ expect(tiptap.getHTML().replaceAll('><', ">\n<")).toBe(output.replace(/\n$/, ''))
+ })
+
+ test('serialize from editor', () => {
+ const tiptap = editorWithContent(markdownit.render(input))
+ const serializer = createMarkdownSerializer(tiptap.schema)
+ expect(serializer.serialize(tiptap.state.doc)).toBe(input.replace(/\n$/, ''))
+ })
+
+ test('handle html table with other structure', () => {
+ const tiptap = editorWithContent(
+ otherStructure.replace(/\n\s*/g,'')
+ )
+ expect(tiptap.getHTML().replaceAll('><', ">\n<")).toBe(output.replace(/\n$/, ''))
+ })
+
+})
+
+function editorWithContent(content) {
+ return createEditor({
+ content,
+ enableRichEditing: true
+ })
+}
+