Add Istanbul for code coverage, parameter tests for 100% coverage.

This commit is contained in:
David Anson 2015-03-11 21:13:21 -07:00
parent 285a30e124
commit 77da8da9cf
3 changed files with 39 additions and 0 deletions

View file

@ -52,6 +52,7 @@ function lintFile(file, config, callback) {
module.exports = function markdownlint(options, callback) {
options = options || {};
callback = callback || function noop() {};
var files = options.files || [];
var config = options.config || { "default": true };
var results = {};

View file

@ -15,6 +15,7 @@
},
"scripts": {
"test": "nodeunit",
"test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit",
"debug": "node debug node_modules/nodeunit/bin/nodeunit",
"lint": "eslint lib test"
},
@ -23,6 +24,7 @@
},
"devDependencies": {
"eslint": "^0.15.0",
"istanbul": "^0.3.7",
"nodeunit": "^0.9.0",
"q": "^1.2.0"
},

View file

@ -66,3 +66,39 @@ fs.readdirSync(__dirname).forEach(function forFile(file) {
module.exports[file] = createTestForFile(path.join(__dirname, file));
}
});
module.exports.missingOptions = function missingOptions(test) {
test.expect(2);
markdownlint(null, function callback(err, result) {
test.ifError(err);
test.ok(result, "Did not get result for missing options.");
test.done();
});
};
module.exports.missingFiles = function missingFiles(test) {
test.expect(2);
markdownlint({}, function callback(err, result) {
test.ifError(err);
test.ok(result, "Did not get result for missing files.");
test.done();
});
};
module.exports.missingCallback = function missingCallback(test) {
test.expect(0);
markdownlint();
test.done();
};
module.exports.badFile = function badFile(test) {
test.expect(3);
markdownlint({
"files": [ "./badFile" ]
}, function callback(err, result) {
test.ok(err, "Did not get an error for bad file.");
test.equal(err.code, "ENOENT", "Error code for bad file not ENOENT.");
test.ok(!result, "Got result for bad file.");
test.done();
});
};