Test(emphasis): prove that emphasis mechanism is working correctly

This test scenario is related to issue #107
This commit is contained in:
Estevão Soares dos Santos 2015-01-16 23:05:12 +00:00
parent f938d2b8aa
commit d4f619c666
3 changed files with 68 additions and 29 deletions

View 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>

View 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

View File

@ -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]));
}
});
})(); })();