Browse Source

Improved tests coverage

pull/41/head
Vitaly Puzrin 10 years ago
parent
commit
0053036571
  1. 1
      package.json
  2. 30
      test/fixtures/markdown-it/commonmark_extras.txt
  3. 19
      test/misc.js

1
package.json

@ -42,6 +42,7 @@
"markdown-it-deflist": "~ 0.1.0", "markdown-it-deflist": "~ 0.1.0",
"markdown-it-emoji": "~ 0.1.3", "markdown-it-emoji": "~ 0.1.3",
"markdown-it-footnote": "~ 0.1.0", "markdown-it-footnote": "~ 0.1.0",
"markdown-it-for-inline": "~ 0.1.0",
"markdown-it-ins": "~ 0.1.0", "markdown-it-ins": "~ 0.1.0",
"markdown-it-mark": "~ 0.1.0", "markdown-it-mark": "~ 0.1.0",
"markdown-it-sub": "~ 0.1.0", "markdown-it-sub": "~ 0.1.0",

30
test/fixtures/markdown-it/commonmark_extras.txt

@ -170,3 +170,33 @@ Coverage. Escape.
. .
<p><em>\a</em></p> <p><em>\a</em></p>
. .
Coverage. parseLinkDestination
.
[foo](<
bar>)
[foo](<bar)
.
<p>[foo](&lt;
bar&gt;)</p>
<p>[foo](&lt;bar)</p>
.
Coverage. parseLinkTitle
.
[foo](bar "ba)
.
<p>[foo](bar &quot;ba)</p>
.
Coverage. parseLinkTitle
.
[foo](bar "ba\
z")
.
<p><a href="bar" title="ba
z">foo</a></p>
.

19
test/misc.js

@ -204,6 +204,15 @@ describe('Misc', function () {
assert.strictEqual(md.render('foo\nbar'), '<p>foo\nbar</p>\n'); assert.strictEqual(md.render('foo\nbar'), '<p>foo\nbar</p>\n');
}); });
it('Should render link target attr', function () {
var md = markdownit()
.use(require('markdown-it-for-inline'), 'target', 'link_open', function (tokens, idx) {
tokens[idx].target = '_blank';
});
assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n');
});
}); });
@ -226,9 +235,17 @@ describe('Links validation', function () {
describe('maxNesting', function () { describe('maxNesting', function () {
it('Inline parser', function () { it('Inline parser should not nest above limit', function () {
var md = markdownit({ maxNesting: 2 }); var md = markdownit({ maxNesting: 2 });
assert.strictEqual(md.render('*foo *bar *baz* bar* foo*'), '<p><em>foo <em>bar *baz* bar</em> foo</em></p>\n'); assert.strictEqual(md.render('*foo *bar *baz* bar* foo*'), '<p><em>foo <em>bar *baz* bar</em> foo</em></p>\n');
}); });
it('Block parser should not nest above limit', function () {
var md = markdownit({ maxNesting: 2 });
assert.strictEqual(
md.render('>foo\n>>bar\n>>>baz'),
'<blockquote>\n<p>foo</p>\n<blockquote>\n</blockquote>\n</blockquote>\n'
);
});
}); });

Loading…
Cancel
Save