Skip to content

Commit

Permalink
more testCases added for codeblock cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nikos-amofa committed Nov 19, 2023
1 parent 7992a00 commit e417c8f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 deletions.
40 changes: 36 additions & 4 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1467,17 +1467,49 @@ test('Test strikethrough with link with URL that contains tilde', () => {
test('Linebreak between end of text and start of code block should be remained', () => {
const testCases = [
{
testString: '```\ncode\n```\ntext\n```\ncode\n```',
resultString: '<pre>code<br /></pre>text<br /><pre>code<br /></pre>',
testString: '```\ncode1\n```\ntext\n```\ncode2\n```',
resultString: '<pre>code1<br /></pre>text<br /><pre>code2<br /></pre>',
},
{
testString: 'A\n```\ncode\n```',
resultString: 'A<br /><pre>code<br /></pre>',
testString: 'text\n```\ncode\n```',
resultString: 'text<br /><pre>code<br /></pre>',
},
{
testString: '|\n```\ncode\n```',
resultString: '|<br /><pre>code<br /></pre>',
},
{
testString: 'text1```code```text2',
resultString: 'text1<pre>code</pre>text2',
},
{
testString: 'text1 ``` code ``` text2',
resultString: 'text1 <pre>&#32;code&#32;</pre> text2',
},
{
testString: 'text1\n```code```\ntext2',
resultString: 'text1<br /><pre>code</pre>text2',
},
{
testString: 'text1\n``` code ```\ntext2',
resultString: 'text1<br /><pre>&#32;code&#32;</pre>text2',
},
{
testString: 'text1\n```\n\ncode\n```\ntext2',
resultString: 'text1<br /><pre><br />code<br /></pre>text2',
},
{
testString: 'text1\n```\n\ncode\n\n```\ntext2',
resultString: 'text1<br /><pre><br />code<br /><br /></pre>text2',
},
{
testString: 'text1\n```\n\n\ncode\n\n```\ntext2',
resultString: 'text1<br /><pre><br /><br />code<br /><br /></pre>text2',
},
{
testString: 'text1\n```\n\ncode\n\n\n```\ntext2',
resultString: 'text1<br /><pre><br />code<br /><br /><br /></pre>text2',
},
];
testCases.forEach(({testString, resultString}) => {
expect(parser.replace(testString)).toBe(resultString);
Expand Down
40 changes: 36 additions & 4 deletions __tests__/ExpensiMark-Markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,49 @@ test('Test codeFence copy from selection does not add extra new line', () => {
test('Linebreak should be remained for text between code block', () => {
const testCases = [
{
testString: '<pre>code<br></pre>text<br><pre>code<br></pre>',
resultString: '```\ncode\n```\ntext\n```\ncode\n```',
testString: '<pre>code1<br></pre>text<br><pre>code2<br></pre>',
resultString: '```\ncode1\n```\ntext\n```\ncode2\n```',
},
{
testString: 'A<br><pre>code<br></pre>',
resultString: 'A\n```\ncode\n```',
testString: 'text<br><pre>code<br></pre>',
resultString: 'text\n```\ncode\n```',
},
{
testString: '|<br><pre>code<br></pre>',
resultString: '|\n```\ncode\n```',
},
{
testString: 'text1<pre>code</pre>text2',
resultString: 'text1```\ncode\n```\ntext2',
},
{
testString: 'text1 <pre>&#32;code&#32;</pre> text2',
resultString: 'text1 ```\n code \n```\n text2',
},
{
testString: 'text1<br><pre>code</pre>text2',
resultString: 'text1\n```\ncode\n```\ntext2',
},
{
testString: 'text1<br><pre>&#32;code&#32;</pre>text2',
resultString: 'text1\n```\n code \n```\ntext2',
},
{
testString: 'text1<br><pre><br>code<br></pre>text2',
resultString: 'text1\n```\n\ncode\n```\ntext2',
},
{
testString: 'text1<br><pre><br>code<br><br></pre>text2',
resultString: 'text1\n```\n\ncode\n\n```\ntext2',
},
{
testString: 'text1<br><pre><br><br>code<br><br></pre>text2',
resultString: 'text1\n```\n\n\ncode\n\n```\ntext2',
},
{
testString: 'text1<br><pre><br>code<br><br><br></pre>text2',
resultString: 'text1\n```\n\ncode\n\n\n```\ntext2',
},
];
testCases.forEach(({testString, resultString}) => {
expect(parser.htmlToMarkdown(testString)).toBe(resultString);
Expand Down

0 comments on commit e417c8f

Please sign in to comment.