12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /*eslint no-script-url:0*/
- import marked from 'app/utils/marked';
- function expectMarkdown(test) {
- expect(marked(test[0])).toEqual('<p>' + test[1] + '</p>\n');
- }
- describe('marked', function() {
- it('normal links get rendered as html', function() {
- for (const test of [
- ['[x](http://example.com)', '<a href="http://example.com">x</a>'],
- ['[x](https://example.com)', '<a href="https://example.com">x</a>'],
- ['[x](mailto:foo@example.com)', '<a href="mailto:foo@example.com">x</a>'],
- ]) {
- expectMarkdown(test);
- }
- });
- it('rejected links should be rendered as plain text', function() {
- for (const test of [
- ['[x](javascript:foo)', 'javascript:foo'],
- ['[x](java\nscript:foo)', '[x](java\nscript:foo)'],
- ['[x](data:foo)', 'data:foo'],
- ['[x](vbscript:foo)', 'vbscript:foo'],
- ]) {
- expectMarkdown(test);
- }
- });
- it('normal images get rendered as html', function() {
- for (const test of [
- ['', '<img src="http://example.com" alt="">'],
- ['', '<img src="http://example.com" alt="x">'],
- ['', '<img src="https://example.com" alt="x">'],
- ]) {
- expectMarkdown(test);
- }
- });
- it("rejected images shouldn't be rendered at all", function() {
- for (const test of [['', '']]) {
- expectMarkdown(test);
- }
- });
- });
|