mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix test failures
This commit is contained in:
parent
00b52df5b1
commit
655dfa0f5f
@ -55,7 +55,6 @@ function getParseFunction(parser, conf) {
|
||||
var parse;
|
||||
|
||||
if (parser === parsers.marked) {
|
||||
parser = require(parser);
|
||||
parser = require(parser);
|
||||
parser.setOptions({
|
||||
gfm: true,
|
||||
@ -68,7 +67,9 @@ function getParseFunction(parser, conf) {
|
||||
});
|
||||
parse = function(source) {
|
||||
source = escapeUnderscores(source);
|
||||
return parser(source);
|
||||
return parser(source)
|
||||
.replace(/\s+$/, '')
|
||||
.replace(/'/g, "'");
|
||||
};
|
||||
parse._parser = parsers.marked;
|
||||
return parse;
|
||||
|
||||
@ -212,7 +212,7 @@ describe("jsdoc/tutorial", function() {
|
||||
env.conf.markdown = {parser: 'evilstreak'};
|
||||
expect(par.parse()).toBe("<h1>This is the parent tutorial's <em>content & stuff</em> A<em>B X</em>Y</h1>");
|
||||
|
||||
env.conf.markdown = {parser: 'gfm'};
|
||||
env.conf.markdown = {parser: 'marked'};
|
||||
expect(par.parse()).toBe("<h1>This is the parent tutorial's <em>content & stuff</em> A_B X_Y</h1>");
|
||||
|
||||
env.conf.markdown = old;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*global describe: true, expect: true, it: true, xit: true */
|
||||
/*global describe: true, env: true, expect: true, it: true, xit: true */
|
||||
describe('jsdoc/util/markdown', function() {
|
||||
var markdown = require('jsdoc/util/markdown');
|
||||
|
||||
@ -45,7 +45,7 @@ describe('jsdoc/util/markdown', function() {
|
||||
var parser = markdown.getParser();
|
||||
expect(typeof parser).toEqual('function');
|
||||
|
||||
setMarkdownConf({parser: 'gfm'});
|
||||
setMarkdownConf({parser: 'marked'});
|
||||
parser = markdown.getParser();
|
||||
expect(typeof parser).toEqual('function');
|
||||
|
||||
@ -59,102 +59,38 @@ describe('jsdoc/util/markdown', function() {
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('should use the GFM parser when requested', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm'});
|
||||
it('should use the marked parser when requested', function() {
|
||||
var storage = setMarkdownConf({parser: 'marked'});
|
||||
var parser = markdown.getParser();
|
||||
expect(parser._parser).toEqual('github-flavored-markdown');
|
||||
expect(parser._parser).toEqual('marked');
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('should use GFM parser when parser is not specified but github owner and repo are', function() {
|
||||
var storage = setMarkdownConf({githubRepoOwner: 'jsdoc', githubRepoName: 'jsdoc3'});
|
||||
it('should use the marked parser when GFM is requested', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm'});
|
||||
var parser = markdown.getParser();
|
||||
expect(parser._parser).toEqual('github-flavored-markdown');
|
||||
expect(parser._parser).toEqual('marked');
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('should convert GitHub repo references to links when the correct options are defined', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm', githubRepoOwner: 'jsdoc', githubRepoName: 'jsdoc3'});
|
||||
var parser = markdown.getParser();
|
||||
expect(parser._parser).toEqual('github-flavored-markdown');
|
||||
|
||||
var sha = '228c940816b5f799a12f83f071a1c67cbb478f39';
|
||||
var sha7 = sha.substr(0, 7);
|
||||
|
||||
// Auto-link sha1 if GitHub.nameWithOwner is defined
|
||||
expect(parser(sha)).toEqual(
|
||||
"<p><a href='http://github.com/jsdoc/jsdoc3/commit/" + sha + "'>" + sha7 + "</a></p>");
|
||||
|
||||
// ** GFM ** Auto-link user@sha1 if GitHub.nameWithOwner is defined
|
||||
expect(parser('mathematicalcoffee@' + sha)).toEqual(
|
||||
"<p><a href='http://github.com/mathematicalcoffee/jsdoc3/commit/" + sha + "'>mathematicalcoffee@" + sha7 + "</a></p>");
|
||||
|
||||
// ** GFM ** Auto-link user/repo@sha1
|
||||
expect(parser('jsdoc/jsdoc3@' + sha)).toEqual(
|
||||
"<p><a href='http://github.com/jsdoc/jsdoc3/commit/" + sha + "'>jsdoc/jsdoc3@" + sha7 + "</a></p>");
|
||||
|
||||
// ** GFM ** Auto-link #issue if GitHub.nameWithOwner is defined
|
||||
expect(parser('Fixes #1')).toEqual(
|
||||
"<p>Fixes <a href='http://github.com/jsdoc/jsdoc3/issues/#issue/1'>#1</a></p>");
|
||||
|
||||
// ** GFM ** Auto-link user#issue if GitHub.nameWithOwner is defined
|
||||
expect(parser('mathematicalcoffee#12')).toEqual(
|
||||
"<p><a href='http://github.com/mathematicalcoffee/jsdoc3/issues/#issue/12'>mathematicalcoffee#12</a></p>");
|
||||
|
||||
// ** GFM ** Auto-link user/repo#issue
|
||||
expect(parser('jsdoc/jsdoc3#1')).toEqual(
|
||||
"<p><a href='http://github.com/jsdoc/jsdoc3/issues/#issue/1'>jsdoc/jsdoc3#1</a></p>");
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('should not apply formatting to inline tags when the evilstreak parser is enabled', function() {
|
||||
it('should not apply formatting to inline tags when the evilstreak parser is enabled', function() {
|
||||
var storage = setMarkdownConf({parser: 'evilstreak'});
|
||||
|
||||
var parser = markdown.getParser();
|
||||
|
||||
// get the evilstreak parser and do the test
|
||||
var parser = markdown.getParser();
|
||||
expect(parser('{@link MyClass#_x} and {@link MyClass#_y}')).toEqual(
|
||||
'<p>{@link MyClass#_x} and {@link MyClass#_y}</p>');
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not apply formatting to inline tags when the GFM parser is enabled', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm'});
|
||||
|
||||
// get the gfm parser and do the test
|
||||
it('should not apply formatting to inline tags when the marked parser is enabled', function() {
|
||||
var storage = setMarkdownConf({parser: 'marked'});
|
||||
var parser = markdown.getParser();
|
||||
|
||||
// get the marked parser and do the test
|
||||
expect(parser('{@link MyClass#_x} and {@link MyClass#_y}')).toEqual(
|
||||
'<p>{@link MyClass#_x} and {@link MyClass#_y}</p>');
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('GFM parser with no conf.markdown.hardwrap has it to false', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm'});
|
||||
|
||||
var parser = markdown.getParser();
|
||||
expect(parser('Testing\nhardwrap')).toEqual('<p>Testing\nhardwrap</p>');
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('GFM parser respects conf.markdown.hardwrap=false', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm', hardwrap: false});
|
||||
|
||||
var parser = markdown.getParser();
|
||||
expect(parser('Testing\nhardwrap')).toEqual('<p>Testing\nhardwrap</p>');
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
|
||||
it('GFM parser respects conf.markdown.hardwrap=true', function() {
|
||||
var storage = setMarkdownConf({parser: 'gfm', hardwrap: true});
|
||||
|
||||
var parser = markdown.getParser();
|
||||
expect(parser('Testing\nhardwrap')).toEqual('<p>Testing<br />hardwrap</p>');
|
||||
|
||||
restoreMarkdownConf(storage);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user