forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed markdown renderer in Playground (microsoft#2073)
* Fixed markdown renderer in Playground * Updated CHANGELOG.md * Fixed markdown renderer in Playground * Updated CHANGELOG.md * Modified renderMarkdown function
- Loading branch information
Showing
5 changed files
with
33 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,60 +4,48 @@ import renderMarkdown from '../renderMarkdown'; | |
|
||
describe('renderMarkdown', () => { | ||
it('should render markdown', () => { | ||
const styleSet = { | ||
options: { | ||
markdownRespectCRLF: true | ||
} | ||
}; | ||
expect(renderMarkdown('**Hello!**', styleSet)).not.toBeFalsy(); | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown('**Hello!**', options)).not.toBeFalsy(); | ||
}); | ||
|
||
it('should properly render newline characters to markdown', () => { | ||
const styleSet = { | ||
options: { | ||
markdownRespectCRLF: true | ||
} | ||
}; | ||
expect(renderMarkdown('Same line.\nSame line. \n2nd line.', styleSet)).toBe( | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown('Same line.\nSame line. \n2nd line.', options)).toBe( | ||
'<p>Same line.\nSame line.<br />\n2nd line.</p>\n' | ||
); | ||
}); | ||
|
||
it('should respect CRFL', () => { | ||
const styleSet = { | ||
options: { | ||
markdownRespectCRLF: true | ||
} | ||
}; | ||
expect(renderMarkdown('Same Line.\n\rSame Line.\r\n2nd line.', styleSet)).toBe( | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown('Same Line.\n\rSame Line.\r\n2nd line.', options)).toBe( | ||
'<p>Same Line.\nSame Line.</p>\n<p>2nd line.</p>\n' | ||
); | ||
}); | ||
|
||
it('should respect LFCR', () => { | ||
const styleSet = { options: { markdownRespectCRLF: false } }; | ||
expect(renderMarkdown('Same Line.\r\nSame Line.\n\r2nd line.', styleSet)).toBe( | ||
const options = { markdownRespectCRLF: false }; | ||
expect(renderMarkdown('Same Line.\r\nSame Line.\n\r2nd line.', options)).toBe( | ||
'<p>Same Line.\nSame Line.</p>\n<p>2nd line.</p>\n' | ||
); | ||
}); | ||
|
||
it('should render bold text', () => { | ||
const styleSet = { options: { markdownRespectCRLF: true } }; | ||
expect(renderMarkdown('**Message with Markdown**\r\nShould see bold text.', styleSet)).toBe( | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown('**Message with Markdown**\r\nShould see bold text.', options)).toBe( | ||
'<p><strong>Message with Markdown</strong></p>\n<p>Should see bold text.</p>\n' | ||
); | ||
}); | ||
|
||
it('should render code correctly', () => { | ||
const styleSet = { options: { markdownRespectCRLF: true } }; | ||
expect(renderMarkdown(`\`\`\`\n${JSON.stringify({ hello: 'World!' }, null, 2)}\n\`\`\``, styleSet)).toBe( | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown(`\`\`\`\n${JSON.stringify({ hello: 'World!' }, null, 2)}\n\`\`\``, options)).toBe( | ||
'<pre><code>{\n "hello": "World!"\n}\n</code></pre>\n' | ||
); | ||
}); | ||
|
||
it('should render sip protocol links correctly', () => { | ||
const styleSet = { options: { markdownRespectCRLF: true } }; | ||
expect(renderMarkdown(`[[email protected]](sip:[email protected])`, styleSet)).toBe( | ||
const options = { markdownRespectCRLF: true }; | ||
expect(renderMarkdown(`[[email protected]](sip:[email protected])`, options)).toBe( | ||
'<p><a href="sip:[email protected]" target="_blank">[email protected]</a></p>\n' | ||
); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters