Skip to content

Commit

Permalink
✅ (#2184): add markdown tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vinicius Reis <[email protected]>
  • Loading branch information
Vinicius Reis committed Mar 10, 2022
1 parent 341f195 commit 322645b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nodes/Callouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default Node.create({

const attributes = {
...this.options.HTMLAttributes,
'data-callout': node.attrs.type,
class: `${classy} ${classy}-${node.attrs.type}`,
}

Expand Down
16 changes: 16 additions & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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:::`)
})
})
})

0 comments on commit 322645b

Please sign in to comment.