2019-10-30 20:37:06 -07:00
|
|
|
// @ts-check
|
|
|
|
|
|
2016-10-06 21:44:39 -07:00
|
|
|
"use strict";
|
|
|
|
|
|
2018-04-27 22:05:34 -07:00
|
|
|
const fs = require("fs");
|
|
|
|
|
const path = require("path");
|
2020-05-08 15:28:38 -07:00
|
|
|
const globby = require("globby");
|
2020-01-08 22:13:51 -08:00
|
|
|
const tape = require("tape");
|
2020-02-15 11:22:16 -08:00
|
|
|
require("tape-player");
|
2018-04-27 22:05:34 -07:00
|
|
|
const markdownlint = require("../lib/markdownlint");
|
2020-01-06 22:09:07 -08:00
|
|
|
const { utf8Encoding } = require("../helpers");
|
2016-10-06 21:44:39 -07:00
|
|
|
|
2020-01-06 22:09:07 -08:00
|
|
|
// Simulates typing each test file to validate handling of partial input
|
|
|
|
|
const files = fs.readdirSync("./test");
|
|
|
|
|
files.filter((file) => /\.md$/.test(file)).forEach((file) => {
|
|
|
|
|
const strings = {};
|
|
|
|
|
let content = fs.readFileSync(path.join("./test", file), utf8Encoding);
|
|
|
|
|
while (content) {
|
|
|
|
|
strings[content.length.toString()] = content;
|
|
|
|
|
content = content.slice(0, -1);
|
|
|
|
|
}
|
2020-01-08 22:13:51 -08:00
|
|
|
tape(`type ${file}`, (test) => {
|
|
|
|
|
test.plan(1);
|
2020-01-06 22:09:07 -08:00
|
|
|
markdownlint.sync({
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
strings,
|
2017-07-05 21:53:21 -07:00
|
|
|
"resultVersion": 0
|
2016-10-06 21:44:39 -07:00
|
|
|
});
|
2020-01-08 22:13:51 -08:00
|
|
|
test.pass();
|
|
|
|
|
test.end();
|
|
|
|
|
});
|
2020-01-06 22:09:07 -08:00
|
|
|
});
|
2016-10-06 21:44:39 -07:00
|
|
|
|
2020-01-06 22:09:07 -08:00
|
|
|
// Parses all Markdown files in all package dependencies
|
2020-01-08 22:13:51 -08:00
|
|
|
tape("parseAllFiles", (test) => {
|
2020-05-08 15:28:38 -07:00
|
|
|
test.plan(1);
|
|
|
|
|
const options = {
|
|
|
|
|
"files": globby.sync("**/*.{md,markdown}")
|
2016-10-06 21:44:39 -07:00
|
|
|
};
|
2020-05-08 15:28:38 -07:00
|
|
|
markdownlint(options, (err) => {
|
2016-10-06 21:44:39 -07:00
|
|
|
test.ifError(err);
|
2020-05-08 15:28:38 -07:00
|
|
|
test.end();
|
2016-10-06 21:44:39 -07:00
|
|
|
});
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|