tape("https://github.com/dotnet/docs", (test) => { const rootDir = dotnetDocsDir; const globPatterns = [ join(rootDir, "**/*.md"), "!" + join(rootDir, "samples/**/*.md") ]; const configPath = join(rootDir, ".markdownlint.json"); lintTestRepo(test, globPatterns, configPath); });
tape("configBadFile", (test) => { test.plan(4); markdownlint.readConfig("./test/config/config-badfile.json", function callback(err, result) { test.ok(err, "Did not get an error for bad file."); test.ok(err instanceof Error, "Error not instance of Error."); // @ts-ignore test.equal(err.code, "ENOENT", "Error code for bad file not ENOENT."); test.ok(!result, "Got result for bad file."); test.end(); }); });
tape("missingOptions", (test) => { test.plan(2); markdownlint(null, function callback(err, result) { test.ifError(err); test.deepEqual(result, {}, "Did not get empty result for missing options."); test.end(); }); });
tape("configBadFileSync", (test) => { test.plan(1); test.throws( function badFileCall() { markdownlint.readConfigSync("./test/config/config-badfile.json"); }, /ENOENT/, "Did not get correct exception for bad file." ); test.end(); });
tape("styleFiles", (test) => { test.plan(4); fs.readdir("./style", function readdir(err, files) { test.ifError(err); files.forEach(function forFile(file) { test.ok(require(path.join("../style", file)), "Unable to load/parse."); }); test.end(); }); });
tape("https://github.com/mkdocs/mkdocs", (test) => { const rootDir = "./test-repos/mkdocs-mkdocs"; const globPatterns = [ join(rootDir, "README.md"), join(rootDir, "CONTRIBUTING.md"), join(rootDir, "docs/*"), "!" + join(rootDir, "docs/CNAME") ]; const configPath = join(rootDir, ".markdownlintrc"); lintTestRepo(test, globPatterns, configPath); });
// Parses all Markdown files in all package dependencies tape("parseAllFiles", (test) => { test.plan(1); const options = { "files": globby.sync("**/*.{md,markdown}") }; markdownlint(options, (err) => { test.ifError(err); test.end(); }); });
tape("configBadChildJson", (test) => { test.plan(3); markdownlint.readConfig("./test/config/config-badchildjson.json", function callback(err, result) { test.ok(err, "Did not get an error for bad child JSON."); test.ok(err instanceof Error, "Error not instance of Error."); test.ok(!result, "Got result for bad child JSON."); test.end(); }); });
tape("https://github.com/pi-hole/docs", (test) => { const rootDir = "./test-repos/pi-hole-docs"; const globPatterns = [ join(rootDir, "**/*.md") ]; const configPath = join(rootDir, ".markdownlint.json"); lintTestRepo(test, globPatterns, configPath); });
tape("configSingleSync", (test) => { test.plan(1); const actual = markdownlint.readConfigSync("./test/config/config-child.json"); const expected = require("./config/config-child.json"); test.deepEqual(actual, expected, "Config object not correct."); test.end(); });
tape("missingCallback", (test) => { test.plan(0); // @ts-ignore markdownlint(); test.end(); });
tape("missingFilesAndStrings", (test) => { test.plan(2); markdownlint({}, function callback(err, result) { test.ifError(err); test.ok(result, "Did not get result for missing files/strings."); test.end(); }); });
// Run markdownlint the same way the corresponding repositories do tape("https://github.com/eslint/eslint", (test) => { const rootDir = "./test-repos/eslint-eslint"; const globPatterns = [ join(rootDir, "docs/**/*.md") ]; const configPath = join(rootDir, ".markdownlint.yml"); lintTestRepo(test, globPatterns, configPath); });
tape("configBadChildJsonSync", (test) => { test.plan(1); test.throws( function badChildJsonCall() { markdownlint.readConfigSync("./test/config/config-badchildjson.json"); }, /Unable to parse '[^']*'; Unexpected token \S+ in JSON at position \d+/, "Did not get correct exception for bad child JSON." ); test.end(); });
tape("configBadJsonSync", (test) => { test.plan(1); test.throws( function badJsonCall() { markdownlint.readConfigSync("./test/config/config-badjson.json"); }, /Unable to parse '[^']*'; Unexpected token \S+ in JSON at position \d+/, "Did not get correct exception for bad JSON." ); test.end(); });