Replace all instances of test.cb(...) with test(new Promise(...)) to prepare for upgrade to AVA@4 where it is not available.

This commit is contained in:
David Anson 2022-06-21 04:40:38 +00:00 committed by GitHub
parent 53cbf063e3
commit 986870061d
4 changed files with 261 additions and 261 deletions

View file

@ -9,30 +9,30 @@ const markdownlint = require("../lib/markdownlint");
const sameFileSystem = (path.relative(os.homedir(), __dirname) !== __dirname);
test.cb("configSingle", (t) => {
test("configSingle", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig("./test/config/config-child.json",
function callback(err, actual) {
t.falsy(err);
const expected = require("./config/config-child.json");
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configAbsolute", (t) => {
test("configAbsolute", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig(path.join(__dirname, "config", "config-child.json"),
function callback(err, actual) {
t.falsy(err);
const expected = require("./config/config-child.json");
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
if (sameFileSystem) {
test.cb("configTilde", (t) => {
test("configTilde", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig(
`~/${path.relative(os.homedir(), "./test/config/config-child.json")}`,
@ -40,12 +40,12 @@ if (sameFileSystem) {
t.falsy(err);
const expected = require("./config/config-child.json");
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
}
test.cb("configMultiple", (t) => {
test("configMultiple", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig("./test/config/config-grandparent.json",
function callback(err, actual) {
@ -57,11 +57,11 @@ test.cb("configMultiple", (t) => {
};
delete expected.extends;
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configMultipleWithRequireResolve", (t) => {
test("configMultipleWithRequireResolve", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig("./test/config/config-packageparent.json",
function callback(err, actual) {
@ -72,11 +72,11 @@ test.cb("configMultipleWithRequireResolve", (t) => {
};
delete expected.extends;
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configCustomFileSystem", (t) => {
test("configCustomFileSystem", (t) => new Promise((resolve) => {
t.plan(3);
const file = "/dir/file.json";
const extended = "~/dir/extended.json";
@ -116,11 +116,11 @@ test.cb("configCustomFileSystem", (t) => {
};
delete expected.extends;
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configBadFile", (t) => {
test("configBadFile", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint.readConfig("./test/config/config-badfile.json",
function callback(err, result) {
@ -129,11 +129,11 @@ test.cb("configBadFile", (t) => {
// @ts-ignore
t.is(err.code, "ENOENT", "Error code for bad file not ENOENT.");
t.true(!result, "Got result for bad file.");
t.end();
resolve();
});
});
}));
test.cb("configBadChildFile", (t) => {
test("configBadChildFile", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint.readConfig("./test/config/config-badchildfile.json",
function callback(err, result) {
@ -143,11 +143,11 @@ test.cb("configBadChildFile", (t) => {
t.is(err.code, "ENOENT",
"Error code for bad child file not ENOENT.");
t.true(!result, "Got result for bad child file.");
t.end();
resolve();
});
});
}));
test.cb("configBadChildPackage", (t) => {
test("configBadChildPackage", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint.readConfig("./test/config/config-badchildpackage.json",
function callback(err, result) {
@ -157,33 +157,33 @@ test.cb("configBadChildPackage", (t) => {
t.is(err.code, "ENOENT",
"Error code for bad child package not ENOENT.");
t.true(!result, "Got result for bad child package.");
t.end();
resolve();
});
});
}));
test.cb("configBadJson", (t) => {
test("configBadJson", (t) => new Promise((resolve) => {
t.plan(3);
markdownlint.readConfig("./test/config/config-badjson.json",
function callback(err, result) {
t.truthy(err, "Did not get an error for bad JSON.");
t.true(err instanceof Error, "Error not instance of Error.");
t.true(!result, "Got result for bad JSON.");
t.end();
resolve();
});
});
}));
test.cb("configBadChildJson", (t) => {
test("configBadChildJson", (t) => new Promise((resolve) => {
t.plan(3);
markdownlint.readConfig("./test/config/config-badchildjson.json",
function callback(err, result) {
t.truthy(err, "Did not get an error for bad child JSON.");
t.true(err instanceof Error, "Error not instance of Error.");
t.true(!result, "Got result for bad child JSON.");
t.end();
resolve();
});
});
}));
test.cb("configSingleYaml", (t) => {
test("configSingleYaml", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig(
"./test/config/config-child.yaml",
@ -193,11 +193,11 @@ test.cb("configSingleYaml", (t) => {
t.falsy(err);
const expected = require("./config/config-child.json");
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configMultipleYaml", (t) => {
test("configMultipleYaml", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig(
"./test/config/config-grandparent.yaml",
@ -212,11 +212,11 @@ test.cb("configMultipleYaml", (t) => {
};
delete expected.extends;
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configMultipleHybrid", (t) => {
test("configMultipleHybrid", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.readConfig(
"./test/config/config-grandparent-hybrid.yaml",
@ -231,11 +231,11 @@ test.cb("configMultipleHybrid", (t) => {
};
delete expected.extends;
t.like(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configBadHybrid", (t) => {
test("configBadHybrid", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint.readConfig(
"./test/config/config-badcontent.txt",
@ -249,9 +249,9 @@ test.cb("configBadHybrid", (t) => {
/^Unable to parse '[^']*'; Parser \d+: Unexpected token \S+ in JSON at position \d+;/
), "Error message unexpected.");
t.true(!result, "Got result for bad child JSON.");
t.end();
resolve();
});
});
}));
test("configSingleSync", (t) => {
t.plan(1);
@ -438,17 +438,17 @@ test("configBadHybridSync", (t) => {
);
});
test.cb("configSinglePromise", (t) => {
test("configSinglePromise", (t) => new Promise((resolve) => {
t.plan(1);
markdownlint.promises.readConfig("./test/config/config-child.json")
.then((actual) => {
const expected = require("./config/config-child.json");
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configCustomFileSystemPromise", (t) => {
test("configCustomFileSystemPromise", (t) => new Promise((resolve) => {
t.plan(4);
const file = path.resolve("/dir/file.json");
const extended = path.resolve("/dir/extended.json");
@ -487,11 +487,11 @@ test.cb("configCustomFileSystemPromise", (t) => {
};
delete expected.extends;
t.deepEqual(actual, expected, "Config object not correct.");
t.end();
resolve();
});
});
}));
test.cb("configBadFilePromise", (t) => {
test("configBadFilePromise", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint.promises.readConfig("./test/config/config-badfile.json")
.then(
@ -499,7 +499,7 @@ test.cb("configBadFilePromise", (t) => {
(error) => {
t.truthy(error, "Did not get an error for bad JSON.");
t.true(error instanceof Error, "Error not instance of Error.");
t.end();
resolve();
}
);
});
}));

View file

@ -8,7 +8,7 @@ const markdownlint = require("../lib/markdownlint");
const customRules = require("./rules/rules.js");
const { homepage, version } = require("../package.json");
test.cb("customRulesV0", (t) => {
test("customRulesV0", (t) => new Promise((resolve) => {
t.plan(4);
const customRulesMd = "./test/custom-rules.md";
const options = {
@ -69,11 +69,11 @@ test.cb("customRulesV0", (t) => {
"./test/custom-rules.md: 7: letter-E-letter-X" +
" Rule that reports an error for lines with the letters 'EX'";
t.is(actualMessage, expectedMessage, "Incorrect message (alias).");
t.end();
resolve();
});
});
}));
test.cb("customRulesV1", (t) => {
test("customRulesV1", (t) => new Promise((resolve) => {
t.plan(3);
const customRulesMd = "./test/custom-rules.md";
const options = {
@ -186,11 +186,11 @@ test.cb("customRulesV1", (t) => {
" Rule that reports an error for lines with the letters 'EX'" +
" [Context: \"text\"]";
t.is(actualMessage, expectedMessage, "Incorrect message.");
t.end();
resolve();
});
});
}));
test.cb("customRulesV2", (t) => {
test("customRulesV2", (t) => new Promise((resolve) => {
t.plan(3);
const customRulesMd = "./test/custom-rules.md";
const options = {
@ -294,11 +294,11 @@ test.cb("customRulesV2", (t) => {
" Rule that reports an error for lines with the letters 'EX'" +
" [Context: \"text\"]";
t.is(actualMessage, expectedMessage, "Incorrect message.");
t.end();
resolve();
});
});
}));
test.cb("customRulesConfig", (t) => {
test("customRulesConfig", (t) => new Promise((resolve) => {
t.plan(2);
const customRulesMd = "./test/custom-rules.md";
const options = {
@ -323,11 +323,11 @@ test.cb("customRulesConfig", (t) => {
"letters-E-X": [ 7 ]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("customRulesNpmPackage", (t) => {
test("customRulesNpmPackage", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": [ require("./rules/npm") ],
@ -344,9 +344,9 @@ test.cb("customRulesNpmPackage", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test("customRulesBadProperty", (t) => {
t.plan(27);
@ -399,7 +399,7 @@ test("customRulesBadProperty", (t) => {
}
});
test.cb("customRulesUsedNameName", (t) => {
test("customRulesUsedNameName", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"customRules": [
@ -418,11 +418,11 @@ test.cb("customRulesUsedNameName", (t) => {
"already used as a name or tag.",
"Incorrect message for duplicate name.");
t.true(!result, "Got result for duplicate name.");
t.end();
resolve();
});
});
}));
test.cb("customRulesUsedNameTag", (t) => {
test("customRulesUsedNameTag", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"customRules": [
@ -440,11 +440,11 @@ test.cb("customRulesUsedNameTag", (t) => {
"Name 'HtMl' of custom rule at index 0 is already used as a name or tag.",
"Incorrect message for duplicate name.");
t.true(!result, "Got result for duplicate name.");
t.end();
resolve();
});
});
}));
test.cb("customRulesUsedTagName", (t) => {
test("customRulesUsedTagName", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"customRules": [
@ -469,11 +469,11 @@ test.cb("customRulesUsedTagName", (t) => {
"already used as a name.",
"Incorrect message for duplicate name.");
t.true(!result, "Got result for duplicate tag.");
t.end();
resolve();
});
});
}));
test.cb("customRulesThrowForFile", (t) => {
test("customRulesThrowForFile", (t) => new Promise((resolve) => {
t.plan(4);
const exceptionMessage = "Test exception message";
markdownlint({
@ -494,9 +494,9 @@ test.cb("customRulesThrowForFile", (t) => {
t.is(err.message, exceptionMessage,
"Incorrect message for function thrown.");
t.true(!result, "Got result for function thrown.");
t.end();
resolve();
});
});
}));
test("customRulesThrowForFileSync", (t) => {
t.plan(1);
@ -524,7 +524,7 @@ test("customRulesThrowForFileSync", (t) => {
);
});
test.cb("customRulesThrowForString", (t) => {
test("customRulesThrowForString", (t) => new Promise((resolve) => {
t.plan(4);
const exceptionMessage = "Test exception message";
markdownlint({
@ -547,9 +547,9 @@ test.cb("customRulesThrowForString", (t) => {
t.is(err.message, exceptionMessage,
"Incorrect message for function thrown.");
t.true(!result, "Got result for function thrown.");
t.end();
resolve();
});
});
}));
test("customRulesThrowForStringSync", (t) => {
t.plan(1);
@ -579,7 +579,7 @@ test("customRulesThrowForStringSync", (t) => {
);
});
test.cb("customRulesOnErrorNull", (t) => {
test("customRulesOnErrorNull", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"customRules": [
@ -605,9 +605,9 @@ test.cb("customRulesOnErrorNull", (t) => {
"Did not get correct exception for null object."
);
t.true(!result, "Got result for function thrown.");
t.end();
resolve();
});
});
}));
test("customRulesOnErrorNullSync", (t) => {
t.plan(1);
@ -868,7 +868,7 @@ test("customRulesOnErrorValid", (t) => {
}
});
test.cb("customRulesOnErrorLazy", (t) => {
test("customRulesOnErrorLazy", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": [
@ -907,11 +907,11 @@ test.cb("customRulesOnErrorLazy", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("customRulesOnErrorModified", (t) => {
test("customRulesOnErrorModified", (t) => new Promise((resolve) => {
t.plan(2);
const errorObject = {
"lineNumber": 1,
@ -967,11 +967,11 @@ test.cb("customRulesOnErrorModified", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("customRulesOnErrorInvalidHandled", (t) => {
test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"customRules": [
@ -1008,9 +1008,9 @@ test.cb("customRulesOnErrorInvalidHandled", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test("customRulesOnErrorInvalidHandledSync", (t) => {
t.plan(1);
@ -1051,7 +1051,7 @@ test("customRulesOnErrorInvalidHandledSync", (t) => {
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
});
test.cb("customRulesFileName", (t) => {
test("customRulesFileName", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": [
@ -1068,11 +1068,11 @@ test.cb("customRulesFileName", (t) => {
};
markdownlint(options, function callback(err) {
t.falsy(err);
t.end();
resolve();
});
});
}));
test.cb("customRulesStringName", (t) => {
test("customRulesStringName", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": [
@ -1091,11 +1091,11 @@ test.cb("customRulesStringName", (t) => {
};
markdownlint(options, function callback(err) {
t.falsy(err);
t.end();
resolve();
});
});
}));
test.cb("customRulesDoc", (t) => {
test("customRulesDoc", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"files": "./doc/CustomRules.md",
@ -1106,11 +1106,11 @@ test.cb("customRulesDoc", (t) => {
t.falsy(err);
const expected = { "./doc/CustomRules.md": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("customRulesLintJavaScript", (t) => {
test("customRulesLintJavaScript", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": customRules.lintJavaScript,
@ -1143,11 +1143,11 @@ test.cb("customRulesLintJavaScript", (t) => {
]
};
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("customRulesValidateJson", (t) => {
test("customRulesValidateJson", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"customRules": customRules.validateJson,
@ -1170,9 +1170,9 @@ test.cb("customRulesValidateJson", (t) => {
]
};
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test("customRulesAsyncThrowsInSyncContext", (t) => {
t.plan(1);
@ -1497,7 +1497,7 @@ for (const flavor of [
for (const inputs of stringScenarios) {
const [ subname, files, strings ] = inputs;
test.cb(`${name}${subname}UnhandledAsync`, (t) => {
test(`${name}${subname}UnhandledAsync`, (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
// @ts-ignore
@ -1511,11 +1511,11 @@ for (const flavor of [
t.true(err instanceof Error, "Error not instance of Error.");
t.is(err.message, errorMessage, "Incorrect message for exception.");
t.true(!result, "Got result for exception.");
t.end();
resolve();
});
});
}));
test.cb(`${name}${subname}HandledAsync`, (t) => {
test(`${name}${subname}HandledAsync`, (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
// @ts-ignore
@ -1528,9 +1528,9 @@ for (const flavor of [
}, function callback(err, actualResult) {
t.falsy(err);
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test(`${name}${subname}UnhandledSync`, (t) => {
t.plan(1);
@ -1615,7 +1615,7 @@ for (const flavor of [
for (const inputs of stringScenarios) {
const [ subname, files, strings ] = inputs;
test.cb(`${name}${subname}Unhandled`, (t) => {
test(`${name}${subname}Unhandled`, (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
// @ts-ignore
@ -1629,11 +1629,11 @@ for (const flavor of [
t.true(err instanceof Error, "Error not instance of Error.");
t.is(err.message, errorMessage, "Incorrect message for rejection.");
t.true(!result, "Got result for rejection.");
t.end();
resolve();
});
});
}));
test.cb(`${name}${subname}Handled`, (t) => {
test(`${name}${subname}Handled`, (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
// @ts-ignore
@ -1660,8 +1660,8 @@ for (const flavor of [
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
}
}

View file

@ -8,7 +8,7 @@ const markdownlint = require("../lib/markdownlint");
const homepage = packageJson.homepage;
const version = packageJson.version;
test.cb("resultObjectToStringNotEnumerable", (t) => {
test("resultObjectToStringNotEnumerable", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -21,11 +21,11 @@ test.cb("resultObjectToStringNotEnumerable", (t) => {
for (const property in result) {
t.not(property, "toString", "Function should not enumerate.");
}
t.end();
resolve();
});
});
}));
test.cb("resultFormattingV0", (t) => {
test("resultFormattingV0", (t) => new Promise((resolve) => {
t.plan(4);
const options = {
"files": [
@ -79,9 +79,9 @@ test.cb("resultFormattingV0", (t) => {
"./test/first_heading_bad_atx.md: 1: first-heading-h1" +
" First heading should be a top-level heading";
t.is(actualMessage, expectedMessage, "Incorrect message (alias).");
t.end();
resolve();
});
});
}));
test("resultFormattingSyncV0", (t) => {
t.plan(3);
@ -138,7 +138,7 @@ test("resultFormattingSyncV0", (t) => {
t.is(actualMessage, expectedMessage, "Incorrect message (alias).");
});
test.cb("resultFormattingV1", (t) => {
test("resultFormattingV1", (t) => new Promise((resolve) => {
t.plan(3);
const options = {
"strings": {
@ -237,11 +237,11 @@ test.cb("resultFormattingV1", (t) => {
" Multiple spaces inside hashes on closed atx style heading" +
" [Context: \"# Multiple spa...tyle heading #\"]";
t.is(actualMessage, expectedMessage, "Incorrect message.");
t.end();
resolve();
});
});
}));
test.cb("resultFormattingV2", (t) => {
test("resultFormattingV2", (t) => new Promise((resolve) => {
t.plan(3);
const options = {
"strings": {
@ -335,11 +335,11 @@ test.cb("resultFormattingV2", (t) => {
" Multiple spaces inside hashes on closed atx style heading" +
" [Context: \"# Multiple spa...tyle heading #\"]";
t.is(actualMessage, expectedMessage, "Incorrect message.");
t.end();
resolve();
});
});
}));
test.cb("resultFormattingV3", (t) => {
test("resultFormattingV3", (t) => new Promise((resolve) => {
t.plan(3);
const options = {
"strings": {
@ -439,11 +439,11 @@ test.cb("resultFormattingV3", (t) => {
"input: 4: MD047/single-trailing-newline" +
" Files should end with a single newline character";
t.is(actualMessage, expectedMessage, "Incorrect message.");
t.end();
resolve();
});
});
}));
test.cb("onePerLineResultVersion0", (t) => {
test("onePerLineResultVersion0", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -460,11 +460,11 @@ test.cb("onePerLineResultVersion0", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("onePerLineResultVersion1", (t) => {
test("onePerLineResultVersion1", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -491,11 +491,11 @@ test.cb("onePerLineResultVersion1", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("onePerLineResultVersion2", (t) => {
test("onePerLineResultVersion2", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -520,11 +520,11 @@ test.cb("onePerLineResultVersion2", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("manyPerLineResultVersion3", (t) => {
test("manyPerLineResultVersion3", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -569,11 +569,11 @@ test.cb("manyPerLineResultVersion3", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("frontMatterResultVersion3", (t) => {
test("frontMatterResultVersion3", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -603,6 +603,6 @@ test.cb("frontMatterResultVersion3", (t) => {
]
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));

View file

@ -30,7 +30,7 @@ const configSchemaStrict = {
"additionalProperties": false
};
test.cb("simpleAsync", (t) => {
test("simpleAsync", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -42,9 +42,9 @@ test.cb("simpleAsync", (t) => {
markdownlint(options, (err, actual) => {
t.falsy(err);
t.is(actual.toString(), expected, "Unexpected results.");
t.end();
resolve();
});
});
}));
test("simpleSync", (t) => {
t.plan(1);
@ -73,7 +73,7 @@ test("simplePromise", (t) => {
});
});
test.cb("projectFilesNoInlineConfig", (t) => {
test("projectFilesNoInlineConfig", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -97,11 +97,11 @@ test.cb("projectFilesNoInlineConfig", (t) => {
"helpers/README.md": []
};
t.deepEqual(actual, expected, "Issue(s) with project files.");
t.end();
resolve();
});
});
}));
test.cb("projectFilesInlineConfig", (t) => {
test("projectFilesInlineConfig", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [ "doc/Rules.md" ],
@ -113,11 +113,11 @@ test.cb("projectFilesInlineConfig", (t) => {
"doc/Rules.md": []
};
t.deepEqual(actual, expected, "Issue(s) with project files.");
t.end();
resolve();
});
});
}));
test.cb("stringInputLineEndings", (t) => {
test("stringInputLineEndings", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -141,11 +141,11 @@ test.cb("stringInputLineEndings", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("inputOnlyNewline", (t) => {
test("inputOnlyNewline", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"strings": {
@ -165,11 +165,11 @@ test.cb("inputOnlyNewline", (t) => {
"crlf": []
};
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("defaultTrue", (t) => {
test("defaultTrue", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -195,11 +195,11 @@ test.cb("defaultTrue", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("defaultFalse", (t) => {
test("defaultFalse", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -219,11 +219,11 @@ test.cb("defaultFalse", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("defaultUndefined", (t) => {
test("defaultUndefined", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -247,11 +247,11 @@ test.cb("defaultUndefined", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("disableRules", (t) => {
test("disableRules", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -276,11 +276,11 @@ test.cb("disableRules", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("enableRules", (t) => {
test("enableRules", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -307,11 +307,11 @@ test.cb("enableRules", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("enableRulesMixedCase", (t) => {
test("enableRulesMixedCase", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -338,11 +338,11 @@ test.cb("enableRulesMixedCase", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("disableTag", (t) => {
test("disableTag", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -367,11 +367,11 @@ test.cb("disableTag", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("enableTag", (t) => {
test("enableTag", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -396,11 +396,11 @@ test.cb("enableTag", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("enableTagMixedCase", (t) => {
test("enableTagMixedCase", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [
@ -425,22 +425,22 @@ test.cb("enableTagMixedCase", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("styleFiles", (t) => {
test("styleFiles", (t) => new Promise((resolve) => {
t.plan(4);
fs.readdir("./style", function readdir(err, files) {
t.falsy(err);
for (const file of files) {
t.truthy(require(path.join("../style", file)), "Unable to load/parse.");
}
t.end();
resolve();
});
});
}));
test.cb("styleAll", (t) => {
test("styleAll", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [ "./test/break-all-the-rules.md" ],
@ -499,11 +499,11 @@ test.cb("styleAll", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("styleRelaxed", (t) => {
test("styleRelaxed", (t) => new Promise((resolve) => {
t.plan(2);
const options = {
"files": [ "./test/break-all-the-rules.md" ],
@ -547,11 +547,11 @@ test.cb("styleRelaxed", (t) => {
};
// @ts-ignore
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("nullFrontMatter", (t) => {
test("nullFrontMatter", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -570,11 +570,11 @@ test.cb("nullFrontMatter", (t) => {
};
// @ts-ignore
t.deepEqual(result, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("customFrontMatter", (t) => {
test("customFrontMatter", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -591,11 +591,11 @@ test.cb("customFrontMatter", (t) => {
"content": []
};
t.deepEqual(result, expectedResult, "Did not get empty results.");
t.end();
resolve();
});
});
}));
test.cb("noInlineConfig", (t) => {
test("noInlineConfig", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -624,11 +624,11 @@ test.cb("noInlineConfig", (t) => {
};
// @ts-ignore
t.deepEqual(result, expectedResult, "Undetected issues.");
t.end();
resolve();
});
});
}));
test.cb("readmeHeadings", (t) => {
test("readmeHeadings", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"files": "README.md",
@ -682,11 +682,11 @@ test.cb("readmeHeadings", (t) => {
t.falsy(err);
const expected = { "README.md": [] };
t.deepEqual(result, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("filesArrayNotModified", (t) => {
test("filesArrayNotModified", (t) => new Promise((resolve) => {
t.plan(2);
const files = [
"./test/atx_heading_spacing.md",
@ -696,11 +696,11 @@ test.cb("filesArrayNotModified", (t) => {
markdownlint({ "files": files }, function callback(err) {
t.falsy(err);
t.deepEqual(files, expectedFiles, "Files modified.");
t.end();
resolve();
});
});
}));
test.cb("filesArrayAsString", (t) => {
test("filesArrayAsString", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"files": "README.md",
@ -713,11 +713,11 @@ test.cb("filesArrayAsString", (t) => {
t.falsy(err);
const expected = { "README.md": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("missingOptions", (t) => {
test("missingOptions", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint(null, function callback(err, result) {
t.falsy(err);
@ -726,18 +726,18 @@ test.cb("missingOptions", (t) => {
{},
"Did not get empty result for missing options."
);
t.end();
resolve();
});
});
}));
test.cb("missingFilesAndStrings", (t) => {
test("missingFilesAndStrings", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({}, function callback(err, result) {
t.falsy(err);
t.truthy(result, "Did not get result for missing files/strings.");
t.end();
resolve();
});
});
}));
test("missingCallback", (t) => {
t.plan(0);
@ -745,7 +745,7 @@ test("missingCallback", (t) => {
markdownlint();
});
test.cb("badFile", (t) => {
test("badFile", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"files": [ "./badFile" ]
@ -755,9 +755,9 @@ test.cb("badFile", (t) => {
// @ts-ignore
t.is(err.code, "ENOENT", "Error code for bad file not ENOENT.");
t.true(!result, "Got result for bad file.");
t.end();
resolve();
});
});
}));
test("badFileSync", (t) => {
t.plan(1);
@ -774,7 +774,7 @@ test("badFileSync", (t) => {
);
});
test.cb("badFilePromise", (t) => {
test("badFilePromise", (t) => new Promise((resolve) => {
t.plan(3);
markdownlint.promises.markdownlint({
"files": [ "./badFile" ]
@ -784,12 +784,12 @@ test.cb("badFilePromise", (t) => {
t.truthy(error, "Did not get an error for bad file.");
t.true(error instanceof Error, "Error not instance of Error.");
t.is(error.code, "ENOENT", "Error code for bad file not ENOENT.");
t.end();
resolve();
}
);
});
}));
test.cb("missingStringValue", (t) => {
test("missingStringValue", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -805,9 +805,9 @@ test.cb("missingStringValue", (t) => {
"empty": []
};
t.deepEqual(result, expectedResult, "Did not get empty results.");
t.end();
resolve();
});
});
}));
test("customFileSystemSync", (t) => {
t.plan(2);
@ -825,7 +825,7 @@ test("customFileSystemSync", (t) => {
t.deepEqual(result[file].length, 1, "Did not report violations.");
});
test.cb("customFileSystemAsync", (t) => {
test("customFileSystemAsync", (t) => new Promise((resolve) => {
t.plan(3);
const file = "/dir/file.md";
const fsApi = {
@ -840,11 +840,11 @@ test.cb("customFileSystemAsync", (t) => {
}, function callback(err, result) {
t.falsy(err);
t.deepEqual(result[file].length, 1, "Did not report violations.");
t.end();
resolve();
});
});
}));
test.cb("readme", (t) => {
test("readme", (t) => new Promise((resolve) => {
t.plan(125);
const tagToRules = {};
for (const rule of rules) {
@ -916,11 +916,11 @@ test.cb("readme", (t) => {
(ruleLeft || "[NO RULE]").toString() + ".");
const tagLeft = Object.keys(tagToRules).shift();
t.true(!tagLeft, "Undocumented tag " + tagLeft + ".");
t.end();
resolve();
});
});
}));
test.cb("rules", (t) => {
test("rules", (t) => new Promise((resolve) => {
t.plan(373);
fs.readFile("doc/Rules.md", "utf8",
(err, contents) => {
@ -1003,9 +1003,9 @@ test.cb("rules", (t) => {
if (rule) {
testTagsAliasesParams(rule);
}
t.end();
resolve();
});
});
}));
test("validateJsonUsingConfigSchemaStrict", (t) => {
const jsonFileRe = /\.json$/i;
@ -1135,7 +1135,7 @@ test("someCustomRulesHaveValidUrl", (t) => {
}
});
test.cb("markdownItPluginsSingle", (t) => {
test("markdownItPluginsSingle", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -1155,11 +1155,11 @@ test.cb("markdownItPluginsSingle", (t) => {
t.falsy(err);
const expected = { "string": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("markdownItPluginsMultiple", (t) => {
test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
t.plan(4);
markdownlint({
"strings": {
@ -1175,11 +1175,11 @@ test.cb("markdownItPluginsMultiple", (t) => {
t.falsy(err);
const expected = { "string": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("markdownItPluginsMathjax", (t) => {
test("markdownItPluginsMathjax", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -1199,11 +1199,11 @@ test.cb("markdownItPluginsMathjax", (t) => {
t.falsy(err);
const expected = { "string": [] };
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("markdownItPluginsMathjaxIssue166", (t) => {
test("markdownItPluginsMathjaxIssue166", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"strings": {
@ -1227,11 +1227,11 @@ $$\n`
};
// @ts-ignore
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test.cb("texmath test files with texmath plugin", (t) => {
test("texmath test files with texmath plugin", (t) => new Promise((resolve) => {
t.plan(2);
markdownlint({
"files": [
@ -1246,9 +1246,9 @@ test.cb("texmath test files with texmath plugin", (t) => {
"./test/texmath-content-violating-md037.md": []
};
t.deepEqual(actual, expected, "Unexpected issues.");
t.end();
resolve();
});
});
}));
test("token-map-spans", (t) => {
t.plan(38);