diff options
author | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-03-10 17:23:31 +0300 |
---|---|---|
committer | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-03-14 17:38:29 +0300 |
commit | 87ef4b7539495d253bb13c26fabf3d9989967207 (patch) | |
tree | 5b27a2431e3c74bef8af7bbac47d700b0cac2ecd /src | |
parent | e068931d4e1f96b3cfa31e30aeabb0e41db3168c (diff) |
✅ (#2184): add markdown tests
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nodes/Callouts.js | 1 | ||||
-rw-r--r-- | src/tests/markdown.spec.js | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/nodes/Callouts.js b/src/nodes/Callouts.js index afc68b0e2..f1ffe8482 100644 --- a/src/nodes/Callouts.js +++ b/src/nodes/Callouts.js @@ -71,6 +71,7 @@ export default Node.create({ const attributes = { ...this.options.HTMLAttributes, + 'data-callout': node.attrs.type, class: `${classy} ${classy}-${node.attrs.type}`, } diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 1dbce6097..1bb86ac39 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -2,6 +2,7 @@ import { createEditor } from './../EditorFactory'; import { createMarkdownSerializer } from './../extensions/Markdown' import spec from "./fixtures/spec" import markdownit from './../markdownit' +import { typesAvailable } from './../markdownit/callouts' const markdownThroughEditor = (markdown) => { const tiptap = createEditor({ @@ -117,6 +118,13 @@ describe('Markdown though editor', () => { expect(markdownThroughEditor('This is a [test] for escaping')).toBe('This is a [test] for escaping') expect(markdownThroughEditor('This is a [test for escaping')).toBe('This is a [test for escaping') }) + + test('callouts', () => { + typesAvailable.forEach(type => { + const entry = `::: ${type}\n!${type}!\n\njust do it\n\n:::` + expect(markdownThroughEditor(entry)).toBe(entry) + }) + }) }) describe('Markdown serializer from html', () => { @@ -136,4 +144,12 @@ describe('Markdown serializer from html', () => { expect(markdownThroughEditorHtml('<ul class="contains-task-list"><li><input type="checkbox" checked /><div><h2>Test</h2><p><strong>content</strong></p></div></li></ul>')).toBe('* [x] Test\n\n **content**') expect(markdownThroughEditorHtml('<ul class="contains-task-list"><li><input type="checkbox" checked /><p>Test</p><h1>Block level headline</h1></li></ul>')).toBe('* [x] Test\n\n # Block level headline') }) + + test('callouts', () => { + typesAvailable.forEach(type => { + expect(markdownThroughEditorHtml( + `<div data-callout="${type}" class="callout callout-${type}"><p>!${type}!</p>just do it<p></p></div>` + )).toBe(`::: ${type}\n!${type}!\n\njust do it\n\n:::`) + }) + }) }) |