mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Add test to verify exported names are stable, add missing test files after earlier refactor.
This commit is contained in:
parent
d4a638101a
commit
5cc88a7759
6 changed files with 137 additions and 9 deletions
|
@ -85,7 +85,6 @@ Thank you!
|
|||
[custom-rules]: doc/CustomRules.md
|
||||
[dependencies]: https://docs.npmjs.com/files/package.json#dependencies
|
||||
[example-com]: https://en.wikipedia.org/wiki/Example.com
|
||||
[markdown-it]: https://www.npmjs.com/package/markdown-it
|
||||
[micromark]: https://www.npmjs.com/package/micromark
|
||||
[new-rule]: https://github.com/DavidAnson/markdownlint/labels/new%20rule
|
||||
[npm-scripts]: https://docs.npmjs.com/misc/scripts
|
||||
|
|
|
@ -59,13 +59,13 @@
|
|||
"lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.mjs",
|
||||
"serial-config-docs": "npm run build-config && npm run build-docs",
|
||||
"serial-declaration": "npm run build-declaration && npm run test-declaration",
|
||||
"test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs test/parse-configuration-test.mjs test/resolve-module-test.mjs helpers/test.cjs",
|
||||
"test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-project.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs test/parse-configuration-test.mjs test/resolve-module-test.mjs helpers/test.cjs",
|
||||
"test-cover": "c8 --100 npm test",
|
||||
"test-declaration": "npm-run-all --continue-on-error --parallel test-declaration-cts test-declaration-mts",
|
||||
"test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --module commonjs --esModuleInterop type-check-commonjs.cts",
|
||||
"test-declaration-mts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-nodenext.mts && tsc --module nodenext type-check-nodenext.mts && node type-check-nodenext.mjs",
|
||||
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
|
||||
"update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs",
|
||||
"update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs",
|
||||
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.mjs",
|
||||
"upgrade": "npx --yes npm-check-updates --upgrade"
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ const exportMappings = new Map([
|
|||
[ "./style/relaxed", "../style/relaxed.json" ]
|
||||
]);
|
||||
|
||||
test("exportMappings", (t) => {
|
||||
test("exportMappings table", (t) => {
|
||||
t.deepEqual(
|
||||
Object.keys(packageJson.exports),
|
||||
[ ...exportMappings.keys() ]
|
||||
|
@ -31,9 +31,10 @@ const jsonRe = /\.json$/u;
|
|||
// const importOptionsJson = { "with": { "type": "json" } };
|
||||
|
||||
for (const [ exportName, exportPath ] of exportMappings) {
|
||||
test(exportName, async(t) => {
|
||||
const exportByName = exportName.replace(/^\./u, packageJson.name);
|
||||
test(`export mapping for ${exportByName}`, async(t) => {
|
||||
t.plan(1);
|
||||
const json = jsonRe.test(exportPath);
|
||||
const exportByName = exportName.replace(/^\./u, packageJson.name);
|
||||
const importExportByName = json ?
|
||||
require(exportByName) :
|
||||
await import(exportByName);
|
||||
|
@ -44,7 +45,22 @@ for (const [ exportName, exportPath ] of exportMappings) {
|
|||
});
|
||||
}
|
||||
|
||||
test("subpathImports", async(t) => {
|
||||
test(`exported names`, async(t) => {
|
||||
t.plan(1);
|
||||
const exportedNames = {};
|
||||
for (const [ exportName, exportPath ] of exportMappings) {
|
||||
const exportByName = exportName.replace(/^\./u, packageJson.name);
|
||||
const json = jsonRe.test(exportPath);
|
||||
const importExportByName = json ?
|
||||
require(exportByName) :
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await import(exportByName);
|
||||
exportedNames[exportByName] = Object.keys(importExportByName);
|
||||
}
|
||||
t.snapshot(exportedNames);
|
||||
});
|
||||
|
||||
test("subpathImports and conditions", async(t) => {
|
||||
t.plan(8);
|
||||
const scenarios = [
|
||||
{ "conditions": "browser", "throws": true },
|
||||
|
|
|
@ -17,7 +17,7 @@ const files = await globby(projectFiles);
|
|||
|
||||
test("projectFiles", (t) => {
|
||||
t.plan(2);
|
||||
t.is(files.length, 60);
|
||||
t.is(files.length, 61);
|
||||
const options = {
|
||||
files,
|
||||
"config": require("../.markdownlint.json")
|
||||
|
@ -40,7 +40,7 @@ test("projectFilesExtendedAscii", (t) => {
|
|||
"doc/md036.md"
|
||||
]);
|
||||
const filteredFiles = files.filter((file) => !ignoreFiles.has(file));
|
||||
t.is(filteredFiles.length, 56);
|
||||
t.is(filteredFiles.length, 57);
|
||||
const options = {
|
||||
"files": filteredFiles,
|
||||
"config": require("../.markdownlint.json"),
|
||||
|
|
113
test/snapshots/markdownlint-test-exports.mjs.md
Normal file
113
test/snapshots/markdownlint-test-exports.mjs.md
Normal file
|
@ -0,0 +1,113 @@
|
|||
# Snapshot report for `test/markdownlint-test-exports.mjs`
|
||||
|
||||
The actual snapshot is saved in `markdownlint-test-exports.mjs.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## exported names
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
markdownlint: [
|
||||
'applyFix',
|
||||
'applyFixes',
|
||||
'getVersion',
|
||||
'resolveModule',
|
||||
],
|
||||
'markdownlint/async': [
|
||||
'lint',
|
||||
'readConfig',
|
||||
],
|
||||
'markdownlint/helpers': [
|
||||
'addError',
|
||||
'addErrorContext',
|
||||
'addErrorDetailIf',
|
||||
'allPunctuation',
|
||||
'allPunctuationNoQuestion',
|
||||
'clearHtmlCommentText',
|
||||
'cloneIfArray',
|
||||
'cloneIfUrl',
|
||||
'default',
|
||||
'ellipsify',
|
||||
'endOfLineGemojiCodeRe',
|
||||
'endOfLineHtmlEntityRe',
|
||||
'escapeForRegExp',
|
||||
'expandTildePath',
|
||||
'frontMatterHasTitle',
|
||||
'frontMatterRe',
|
||||
'getHtmlAttributeRe',
|
||||
'getPreferredLineEnding',
|
||||
'getReferenceLinkImageData',
|
||||
'hasOverlap',
|
||||
'inlineCommentStartRe',
|
||||
'isBlankLine',
|
||||
'isEmptyString',
|
||||
'isNumber',
|
||||
'isObject',
|
||||
'isString',
|
||||
'isUrl',
|
||||
'newLineRe',
|
||||
'nextLinesRe',
|
||||
],
|
||||
'markdownlint/promise': [
|
||||
'extendConfig',
|
||||
'lint',
|
||||
'readConfig',
|
||||
],
|
||||
'markdownlint/style/all': [
|
||||
'comment',
|
||||
'default',
|
||||
],
|
||||
'markdownlint/style/cirosantilli': [
|
||||
'comment',
|
||||
'default',
|
||||
'MD003',
|
||||
'MD004',
|
||||
'MD007',
|
||||
'MD030',
|
||||
'MD033',
|
||||
'MD035',
|
||||
],
|
||||
'markdownlint/style/prettier': [
|
||||
'comment',
|
||||
'blanks-around-fences',
|
||||
'blanks-around-headings',
|
||||
'blanks-around-lists',
|
||||
'code-fence-style',
|
||||
'emphasis-style',
|
||||
'heading-start-left',
|
||||
'heading-style',
|
||||
'hr-style',
|
||||
'line-length',
|
||||
'list-indent',
|
||||
'list-marker-space',
|
||||
'no-blanks-blockquote',
|
||||
'no-hard-tabs',
|
||||
'no-missing-space-atx',
|
||||
'no-missing-space-closed-atx',
|
||||
'no-multiple-blanks',
|
||||
'no-multiple-space-atx',
|
||||
'no-multiple-space-blockquote',
|
||||
'no-multiple-space-closed-atx',
|
||||
'no-trailing-spaces',
|
||||
'ol-prefix',
|
||||
'strong-style',
|
||||
'ul-indent',
|
||||
],
|
||||
'markdownlint/style/relaxed': [
|
||||
'comment',
|
||||
'default',
|
||||
'whitespace',
|
||||
'line_length',
|
||||
'ul-indent',
|
||||
'no-inline-html',
|
||||
'no-bare-urls',
|
||||
'fenced-code-language',
|
||||
'first-line-h1',
|
||||
],
|
||||
'markdownlint/sync': [
|
||||
'lint',
|
||||
'readConfig',
|
||||
],
|
||||
}
|
BIN
test/snapshots/markdownlint-test-exports.mjs.snap
Normal file
BIN
test/snapshots/markdownlint-test-exports.mjs.snap
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue