diff --git a/src/components/MarkupItReactRenderer/__tests__/MarkupItReactRenderer.spec.js b/src/components/MarkupItReactRenderer/__tests__/MarkupItReactRenderer.spec.js index c676757f..cdf49cc5 100644 --- a/src/components/MarkupItReactRenderer/__tests__/MarkupItReactRenderer.spec.js +++ b/src/components/MarkupItReactRenderer/__tests__/MarkupItReactRenderer.spec.js @@ -8,22 +8,21 @@ import MarkupIt from 'markup-it'; import markdownSyntax from 'markup-it/syntaxes/markdown'; import htmlSyntax from 'markup-it/syntaxes/html'; import reInline from 'markup-it/syntaxes/markdown/re/inline'; -import MarkupItReactRenderer from '../../UI/MarkupItReactRenderer/MarkupItReactRenderer'; +import MarkupItReactRenderer from '../'; describe('MarkitupReactRenderer', () => { - describe('basics', () => { it('should re-render properly after a value and syntax update', () => { const component = shallow( ); const tree1 = component.html(); component.setProps({ value: '

Title

', - syntax: htmlSyntax + syntax: htmlSyntax, }); const tree2 = component.html(); expect(tree1).toEqual(tree2); @@ -32,8 +31,8 @@ describe('MarkitupReactRenderer', () => { it('should not update the parser if syntax didn\'t change', () => { const component = shallow( ); const syntax1 = component.instance().props.syntax; @@ -76,8 +75,8 @@ Text with **bold** & _em_ elements `; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -86,12 +85,12 @@ Text with **bold** & _em_ elements describe('Headings', () => { for (const heading of [...Array(6).keys()]) { - it(`should render Heading ${heading + 1}`, () => { + it(`should render Heading ${ heading + 1 }`, () => { const value = padStart(' Title', heading + 7, '#'); const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -114,8 +113,8 @@ Text with **bold** & _em_ elements `; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -133,8 +132,8 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] `; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -146,8 +145,8 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] const value = 'Use the `printf()` function.'; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -157,8 +156,8 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] const value = '``There is a literal backtick (`) here.``'; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -184,8 +183,8 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] `; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -195,27 +194,27 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] describe('custom elements', () => { it('should extend default renderers with custom ones', () => { - const myRule = MarkupIt.Rule('mediaproxy') + const myRule = MarkupIt.Rule('mediaproxy') // eslint-disable-line .regExp(reInline.link, (state, match) => { if (match[0].charAt(0) !== '!') { - return; + return null; } return { data: Map({ alt: match[1], src: match[2], - title: match[3] - }).filter(Boolean) + title: match[3], + }).filter(Boolean), }; }); const myCustomSchema = { - 'mediaproxy': ({ token }) => { + mediaproxy: ({ token }) => { //eslint-disable-line const src = token.getIn(['data', 'src']); const alt = token.getIn(['data', 'alt']); - return {alt}/; - } + return {alt}; + }, }; const myMarkdownSyntax = markdownSyntax.addInlineRules(myRule); @@ -226,9 +225,9 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] `; const component = shallow( ); expect(component.html()).toMatchSnapshot(); @@ -240,8 +239,8 @@ I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3] const value = '

Paragraph with inline element

'; const component = shallow( ); expect(component.html()).toMatchSnapshot(); diff --git a/src/components/MarkupItReactRenderer/__tests__/__snapshots__/MarkupItReactRenderer.spec.js.snap b/src/components/MarkupItReactRenderer/__tests__/__snapshots__/MarkupItReactRenderer.spec.js.snap new file mode 100644 index 00000000..82d17c3b --- /dev/null +++ b/src/components/MarkupItReactRenderer/__tests__/__snapshots__/MarkupItReactRenderer.spec.js.snap @@ -0,0 +1,40 @@ +exports[`MarkitupReactRenderer HTML rendering should render HTML 1`] = `"

Paragraph with inline element

"`; + +exports[`MarkitupReactRenderer Markdown rendering Code should render code 1`] = `"

Use the printf() function.

"`; + +exports[`MarkitupReactRenderer Markdown rendering Code should render code 2 1`] = `"

There is a literal backtick (\`) here.

"`; + +exports[`MarkitupReactRenderer Markdown rendering General should render markdown 1`] = `"

H1

Text with bold & em elements

H2

  • ul item 1
  • ul item 2

H3

  1. ol item 1
  2. ol item 2
  3. ol item 3

H4

link title

H5

\"alt

H6
"`; + +exports[`MarkitupReactRenderer Markdown rendering HTML should render HTML as is when using Markdown 1`] = ` +"

Title

+ +
+
Test HTML content
+
Testing HTML in Markdown
+
+
+ +

Test

+
" +`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 1 1`] = `"

Title

"`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 2 1`] = `"

Title

"`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 3 1`] = `"

Title

"`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 4 1`] = `"

Title

"`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 5 1`] = `"
Title
"`; + +exports[`MarkitupReactRenderer Markdown rendering Headings should render Heading 6 1`] = `"
Title
"`; + +exports[`MarkitupReactRenderer Markdown rendering Links should render links 1`] = `""`; + +exports[`MarkitupReactRenderer Markdown rendering Lists should render lists 1`] = `"
  1. ol item 1
  2. ol item 2
    • Sublist 1
    • Sublist 2
    • Sublist 3
      1. Sub-Sublist 1
      2. Sub-Sublist 2
      3. Sub-Sublist 3
  3. ol item 3
"`; + +exports[`MarkitupReactRenderer custom elements should extend default renderers with custom ones 1`] = `"

Title

\"mediaproxy

"`;