Files
wehub-resource-sync 311a3666c4
Build documentation / build (push) Failing after 0s
Unit tests / build (18) (push) Has been cancelled
Unit tests / build (20) (push) Has been cancelled
Unit tests / build (22) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:44:39 +08:00

42 lines
1.3 KiB
JavaScript

import { readdirSync } from "node:fs";
import { dirname, join, relative } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import * as transformers from "../src/transformers.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
const MODELS_DIR = join(__dirname, "..", "src", "models");
function findModelingFiles(dir) {
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const path = join(dir, entry.name);
if (entry.isDirectory()) {
return findModelingFiles(path);
}
return entry.isFile() && entry.name.startsWith("modeling_") && entry.name.endsWith(".js") ? [path] : [];
});
}
function isPublicModelingFile(file) {
return !file.endsWith(join("models", "modeling_utils.js"));
}
describe("Public exports", () => {
it("exports every public modeling_* symbol from the root entry point", async () => {
const missing = [];
for (const file of findModelingFiles(MODELS_DIR).filter(isPublicModelingFile).sort()) {
const moduleExports = await import(pathToFileURL(file).href);
for (const exportName of Object.keys(moduleExports)) {
if (!Object.hasOwn(transformers, exportName)) {
missing.push(`${relative(MODELS_DIR, file)}: ${exportName}`);
}
}
}
expect(missing).toEqual([]);
});
});