Skip to content

Commit

Permalink
Removed outdated code from test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Dec 15, 2014
1 parent 52e1277 commit ac5173e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 50 deletions.
2 changes: 1 addition & 1 deletion test/commonmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ var Remarked = require('../');
describe('CommonMark', function () {
var md = new Remarked('commonmark');

utils.addSpecTests(path.join(__dirname, 'fixtures/commonmark/good.txt'), md);
utils.addTests(path.join(__dirname, 'fixtures/commonmark/good.txt'), md);
});
2 changes: 1 addition & 1 deletion test/remarkable.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ describe('remarkable', function () {
linkify: true
});

utils.addSpecTests(path.join(__dirname, 'fixtures/remarkable'), md);
utils.addTests(path.join(__dirname, 'fixtures/remarkable'), md);
});
50 changes: 2 additions & 48 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,7 @@ var path = require('path');
var assert = require('assert');


function addTests(dir, md, skip) {
var files = fs.readdirSync(dir);
var fixtures = {};

files.forEach(function (name) {
var filePath = path.join(dir, name);
var stat = fs.statSync(filePath);

if (stat.isDirectory()) {
describe(name, function () {
addTests(filePath, md, skip);
});
return;
}

if (stat.isFile()) {
fixtures[name] = fs.readFileSync(path.join(dir, name), 'utf8');
}
});

Object.keys(fixtures).forEach(function (name) {
var src, right,
ext = path.extname(name),
base = path.basename(name, ext);

if ([ '.md', '.markdown' ].indexOf(ext) !== -1) {
src = fixtures[name];
right = fixtures[base + '.html'];

// if no .html pair found - that's doc file, skip it
if (!right) { return; }

if (!skip) {
it(base, function () {
assert.strictEqual(md.render(src), right);
});
} else {
it.skip(base, function () {
assert.strictEqual(md.render(src), right);
});
}
}
});
}

function addSpecTests(fPath, markdown, skip) {
function addTests(fPath, markdown, skip) {
var input,
stat = fs.statSync(fPath);

Expand Down Expand Up @@ -83,11 +38,10 @@ function addSpecTests(fPath, markdown, skip) {

if (stat.isDirectory()) {
fs.readdirSync(fPath).forEach(function (name) {
addSpecTests(path.join(fPath, name), markdown, skip);
addTests(path.join(fPath, name), markdown, skip);
});
}
}


module.exports.addTests = addTests;
module.exports.addSpecTests = addSpecTests;

0 comments on commit ac5173e

Please sign in to comment.