mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +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
|
@ -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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue