From ac5173ead5b7c54337d6cb60880f5881d6d6b191 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Mon, 15 Dec 2014 07:44:32 +0300 Subject: [PATCH] Removed outdated code from test helpers --- test/commonmark.js | 2 +- test/remarkable.js | 2 +- test/utils.js | 50 ++-------------------------------------------- 3 files changed, 4 insertions(+), 50 deletions(-) diff --git a/test/commonmark.js b/test/commonmark.js index c5a3f47..6afe236 100644 --- a/test/commonmark.js +++ b/test/commonmark.js @@ -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); }); diff --git a/test/remarkable.js b/test/remarkable.js index ddb3e85..b2063b4 100644 --- a/test/remarkable.js +++ b/test/remarkable.js @@ -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); }); diff --git a/test/utils.js b/test/utils.js index 69a7df5..88f826e 100644 --- a/test/utils.js +++ b/test/utils.js @@ -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); @@ -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;