mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const glob = require("glob");
|
|
const tape = require("tape");
|
|
require("tape-player");
|
|
const markdownlint = require("../lib/markdownlint");
|
|
const { utf8Encoding } = require("../helpers");
|
|
|
|
// 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);
|
|
}
|
|
tape(`type ${file}`, (test) => {
|
|
test.plan(1);
|
|
markdownlint.sync({
|
|
// @ts-ignore
|
|
strings,
|
|
"resultVersion": 0
|
|
});
|
|
test.pass();
|
|
test.end();
|
|
});
|
|
});
|
|
|
|
// Parses all Markdown files in all package dependencies
|
|
tape("parseAllFiles", (test) => {
|
|
test.plan(2);
|
|
const globOptions = {
|
|
// "cwd": "/",
|
|
"realpath": true
|
|
};
|
|
glob("**/*.{md,markdown}", globOptions, (err, matches) => {
|
|
test.ifError(err);
|
|
const markdownlintOptions = {
|
|
"files": matches
|
|
};
|
|
markdownlint(markdownlintOptions, (errr) => {
|
|
test.ifError(errr);
|
|
test.end();
|
|
});
|
|
});
|
|
});
|