// 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(); }); });
test(`coverage is ignored if it's ${JSON.stringify(arg)}`, function (t) { t.plan(2) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, arg, function (err) { t.ifError(err) fs.readdir(nyc, function (err) { t.is(err.code, 'ENOENT') }) }) })
test('cli prints out version with -v', function (t) { exec(`node ${bin} -v`, { env }, (err, stdout, stderr) => { t.ifError(err, 'no error') t.is(stdout.trim(), '3.0.0') t.is(stderr.trim(), '') t.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(); }); });
test('error', function (t) { t.ifError(new Error('test')) t.end() })
test('write and clean coverage', function (t) { t.plan(3) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, { fake: 123 }, function (err) { t.ifError(err) t.same(fs.readdirSync(nyc), [ 'airtap-0772e0c7c3987f74bb8a740830f7ed2a462a3067.json' ]) fs.writeFileSync(path.join(nyc, 'other'), '') cc.clean(cwd) t.same(fs.readdirSync(nyc), ['other']) }) })
tape("configSingle", (test) => { test.plan(2); markdownlint.readConfig("./test/config/config-child.json", function callback(err, actual) { test.ifError(err); const expected = require("./config/config-child.json"); test.deepEqual(actual, expected, "Config object not correct."); test.end(); }); });
test('message server closes connection without valid cid', function (t) { t.plan(3) const server = new MessageServer() server.open(function (err) { t.ifError(err, 'no open error') const socket = engineClient(`ws://localhost:${server.port}`, { path: '/airtap/msg' }) socket.on('close', function () { t.pass('closed') server.close(function (err) { t.ifError(err, 'no close error') }) }) }) })
tape("configAbsolute", (test) => { test.plan(2); markdownlint.readConfig(path.join(__dirname, "config", "config-child.json"), function callback(err, actual) { test.ifError(err); const expected = require("./config/config-child.json"); test.deepEqual(actual, expected, "Config object not correct."); test.end(); }); });
tape("configSingleYaml", (test) => { test.plan(2); markdownlint.readConfig( "./test/config/config-child.yaml", [ require("js-yaml").safeLoad ], function callback(err, actual) { test.ifError(err); const expected = require("./config/config-child.json"); test.deepEqual(actual, expected, "Config object not correct."); 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("filesArrayNotModified", (test) => { test.plan(2); const files = [ "./test/atx_heading_spacing.md", "./test/first_heading_bad_atx.md" ]; const expectedFiles = files.slice(); markdownlint({ "files": files }, function callback(err) { test.ifError(err); test.deepEqual(files, expectedFiles, "Files modified."); test.end(); }); });
tape("configMultiple", (test) => { test.plan(2); markdownlint.readConfig("./test/config/config-grandparent.json", function callback(err, actual) { test.ifError(err); const expected = { ...require("./config/config-child.json"), ...require("./config/config-parent.json"), ...require("./config/config-grandparent.json") }; delete expected.extends; test.deepEqual(actual, expected, "Config object not correct."); 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(); }); });
tape("customRulesDoc", (test) => { test.plan(2); markdownlint({ "files": "doc/CustomRules.md", "config": { "MD013": { "line_length": 200 } } }, function callback(err, actual) { test.ifError(err); const expected = { "doc/CustomRules.md": [] }; test.deepEqual(actual, expected, "Unexpected issues."); test.end(); }); });