diff --git a/package.json b/package.json index 546f2e15..d31af1f6 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,9 @@ }, "bugs": "https://github.com/DavidAnson/markdownlint/issues", "scripts": { - "test": "nodeunit", - "test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit", + "test": "nodeunit test/markdownlint-test.js", + "test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit test/markdownlint-test.js", + "test-extra": "nodeunit test/markdownlint-test-extra.js", "debug": "node debug node_modules/nodeunit/bin/nodeunit", "lint": "eslint lib test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0\" demo && eslint --rule \"no-console: 0, no-shadow: 0\" example", "build-config-schema": "node schema/build-config-schema.js", diff --git a/test/markdownlint-test-extra.js b/test/markdownlint-test-extra.js new file mode 100644 index 00000000..cc98d2de --- /dev/null +++ b/test/markdownlint-test-extra.js @@ -0,0 +1,56 @@ +"use strict"; + +var fs = require("fs"); +var path = require("path"); +var glob = require("glob"); +var markdownlint = require("../lib/markdownlint"); +var shared = require("../lib/shared"); + +module.exports.typeTestFiles = function typeTestFiles(test) { + // Simulates typing each test file to validate handling of partial input + function validate(file, content) { + var results = markdownlint.sync({ + "strings": { + "content": content + } + }); + var contentLineCount = content.split(shared.newLineRe).length; + Object.keys(results.content).forEach(function forKey(ruleName) { + results.content[ruleName].forEach(function forLine(line) { + test.ok((line >= 1) && (line <= contentLineCount), + "Line number out of range: " + line + + " (" + file + ", " + content.length + ", " + ruleName + ")"); + }); + }); + } + var files = fs.readdirSync("./test"); + files.forEach(function forFile(file) { + if (/\.md$/.test(file)) { + var content = fs.readFileSync( + path.join("./test", file), shared.utf8Encoding); + while (content) { + validate(file, content); + content = content.slice(0, -1); + } + } + }); + test.done(); +}; + +module.exports.parseAllFiles = function parseAllFiles(test) { + // Parses all Markdown files in all dependencies + var globOptions = { + // "cwd": "/", + "realpath": true + }; + glob("**/*.{md,markdown}", globOptions, function globCallback(err, matches) { + test.ifError(err); + var markdownlintOptions = { + "files": matches + }; + markdownlint(markdownlintOptions, function markdownlintCallback(errr) { + test.ifError(errr); + test.done(); + }); + }); +}; diff --git a/test/markdownlint-test.js b/test/markdownlint-test.js index 74c16654..026bedf4 100644 --- a/test/markdownlint-test.js +++ b/test/markdownlint-test.js @@ -4,7 +4,6 @@ var fs = require("fs"); var path = require("path"); var md = require("markdown-it")(); var Q = require("q"); -var glob = require("glob"); var tv4 = require("tv4"); var markdownlint = require("../lib/markdownlint"); var shared = require("../lib/shared"); @@ -933,54 +932,6 @@ module.exports.doc = function doc(test) { }); }; -module.exports.typeTestFiles = function typeTestFiles(test) { - // Simulates typing each test file to validate handling of partial input - function validate(file, content) { - var results = markdownlint.sync({ - "strings": { - "content": content - } - }); - var contentLineCount = content.split(shared.newLineRe).length; - Object.keys(results.content).forEach(function forKey(ruleName) { - results.content[ruleName].forEach(function forLine(line) { - test.ok((line >= 1) && (line <= contentLineCount), - "Line number out of range: " + line + - " (" + file + ", " + content.length + ", " + ruleName + ")"); - }); - }); - } - var files = fs.readdirSync("./test"); - files.forEach(function forFile(file) { - if (/\.md$/.test(file)) { - var content = fs.readFileSync( - path.join("./test", file), shared.utf8Encoding); - while (content) { - validate(file, content); - content = content.slice(0, -1); - } - } - }); - test.done(); -}; - -module.exports.parseAllFiles = function parseAllFiles(test) { - var globOptions = { - // "cwd": "/", - "realpath": true - }; - glob("**/*.{md,markdown}", globOptions, function globCallback(err, matches) { - test.ifError(err); - var markdownlintOptions = { - "files": matches - }; - markdownlint(markdownlintOptions, function markdownlintCallback(errr) { - test.ifError(errr); - test.done(); - }); - }); -}; - module.exports.validateConfigSchema = function validateConfigSchema(test) { var jsonFileRe = /\.json$/i; var testDirectory = __dirname;