mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
Test(emphasis): prove that emphasis mechanism is working correctly
This test scenario is related to issue #107
This commit is contained in:
parent
f938d2b8aa
commit
d4f619c666
11
test/issues/#107.inner_underscore_parse_to_block.html
Normal file
11
test/issues/#107.inner_underscore_parse_to_block.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<p>escaped word_with_underscores</p>
|
||||||
|
|
||||||
|
<p>escaped word__with__double underscores</p>
|
||||||
|
|
||||||
|
<p>escaped word<em>_with_</em>single italic underscore</p>
|
||||||
|
|
||||||
|
<p>escaped word*with*asterixs</p>
|
||||||
|
|
||||||
|
<p>escaped word**with**asterixs</p>
|
||||||
|
|
||||||
|
<p>escaped word<strong>*with*</strong>bold asterixs</p>
|
11
test/issues/#107.inner_underscore_parse_to_block.md
Normal file
11
test/issues/#107.inner_underscore_parse_to_block.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
escaped word\_with\_underscores
|
||||||
|
|
||||||
|
escaped word\_\_with\_\_double underscores
|
||||||
|
|
||||||
|
escaped word_\_with\__single italic underscore
|
||||||
|
|
||||||
|
escaped word\*with*asterixs
|
||||||
|
|
||||||
|
escaped word\*\*with\*\*asterixs
|
||||||
|
|
||||||
|
escaped word**\*with\***bold asterixs
|
|
@ -8,30 +8,55 @@
|
||||||
require('source-map-support').install();
|
require('source-map-support').install();
|
||||||
require('chai').should();
|
require('chai').should();
|
||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
dir = 'test/cases/',
|
showdown = require('../../../dist/showdown.js'),
|
||||||
showdown = require('../../../dist/showdown.js'),
|
converter = new showdown.Converter(),
|
||||||
converter = new showdown.Converter();
|
cases = fs
|
||||||
|
.readdirSync('test/cases/')
|
||||||
|
.filter(filter())
|
||||||
|
.map(map('test/cases/')),
|
||||||
|
issues = fs
|
||||||
|
.readdirSync('test/issues/')
|
||||||
|
.filter(filter())
|
||||||
|
.map(map('test/issues/'));
|
||||||
|
|
||||||
// Load test cases from disk
|
//Tests
|
||||||
var cases = fs.readdirSync(dir).filter(function (file) {
|
describe('Converter.makeHtml() simple testcases', function () {
|
||||||
var ext = file.slice(-3);
|
for (var i = 0; i < cases.length; ++i) {
|
||||||
return (ext === '.md');
|
it(cases[i].name, assertion(cases[i]));
|
||||||
}).map(function (file) {
|
}
|
||||||
|
|
||||||
var name = file.replace('.md', ''),
|
|
||||||
htmlPath = dir + name + '.html',
|
|
||||||
html = fs.readFileSync(htmlPath, 'utf8'),
|
|
||||||
mdPath = dir + name + '.md',
|
|
||||||
md = fs.readFileSync(mdPath, 'utf8');
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: name,
|
|
||||||
input: md,
|
|
||||||
expected: html
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Converter.makeHtml() issues testcase', function () {
|
||||||
|
for (var i = 0; i < issues.length; ++i) {
|
||||||
|
it(issues[i].name, assertion(issues[i]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function filter() {
|
||||||
|
return function(file) {
|
||||||
|
var ext = file.slice(-3);
|
||||||
|
return (ext === '.md');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function map(dir) {
|
||||||
|
return function(file) {
|
||||||
|
var name = file.replace('.md', ''),
|
||||||
|
htmlPath = dir + name + '.html',
|
||||||
|
html = fs.readFileSync(htmlPath, 'utf8'),
|
||||||
|
mdPath = dir + name + '.md',
|
||||||
|
md = fs.readFileSync(mdPath, 'utf8');
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: name,
|
||||||
|
input: md,
|
||||||
|
expected: html
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//Normalize input/output
|
//Normalize input/output
|
||||||
function normalize(testCase) {
|
function normalize(testCase) {
|
||||||
|
|
||||||
|
@ -69,12 +94,4 @@
|
||||||
testCase.actual.should.equal(testCase.expected);
|
testCase.actual.should.equal(testCase.expected);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tests
|
|
||||||
describe('Converter.makeHtml()', function () {
|
|
||||||
for (var i = 0; i < cases.length; ++i) {
|
|
||||||
it(cases[i].name, assertion(cases[i]));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user