Initial Commit
This commit is contained in:
52
packages/api-stack/api/api-manifest/tests/dep-graph.test.ts
Normal file
52
packages/api-stack/api/api-manifest/tests/dep-graph.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const PKG = join(__dirname, "..", "package.json");
|
||||
const SRC = join(__dirname, "..", "src");
|
||||
|
||||
describe("@suaveplan/api-manifest package shape", () => {
|
||||
it("depends on the expected set of workspace + catalog packages", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const pkg = JSON.parse(readFileSync(PKG, "utf8")) as {
|
||||
dependencies: Record<string, string>;
|
||||
};
|
||||
const deps = Object.keys(pkg.dependencies).sort();
|
||||
expect(deps).toEqual([
|
||||
"@suaveplan/api-types",
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/types",
|
||||
"tslib",
|
||||
"zod",
|
||||
]);
|
||||
});
|
||||
|
||||
it("every src file uses default-import z (no named import)", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const offenders: string[] = [];
|
||||
walk(SRC, (file) => {
|
||||
if (!file.endsWith(".ts")) return;
|
||||
const content = readFileSync(file, "utf8");
|
||||
if (/import\s*\{\s*z\s*\}\s*from\s*["']zod["']/.test(content)) {
|
||||
offenders.push(file);
|
||||
}
|
||||
});
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
it("root barrel has no export-star", { timeout: 5000 }, () => {
|
||||
const content = readFileSync(join(SRC, "index.ts"), "utf8");
|
||||
expect(/export\s*\*/.test(content)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
function walk(dir: string, fn: (file: string) => void): void {
|
||||
for (const name of readdirSync(dir)) {
|
||||
const p = join(dir, name);
|
||||
const st = statSync(p);
|
||||
if (st.isDirectory()) walk(p, fn);
|
||||
else fn(p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
39
packages/api-stack/api/api-manifest/tests/subpaths.test.ts
Normal file
39
packages/api-stack/api/api-manifest/tests/subpaths.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
import * as cap from "../src/capability-resolver/index.js";
|
||||
import * as depGraph from "../src/dep-graph/index.js";
|
||||
import * as errorCodes from "../src/error-codes/index.js";
|
||||
import * as hash from "../src/hash/index.js";
|
||||
import * as root from "../src/index.js";
|
||||
import * as parse from "../src/parse/index.js";
|
||||
import * as schema from "../src/schema/index.js";
|
||||
import * as testing from "../src/testing/index.js";
|
||||
import * as validators from "../src/validators/index.js";
|
||||
|
||||
describe("every documented subpath is importable", () => {
|
||||
it("subpath barrels expose their public surface", { timeout: 5000 }, () => {
|
||||
expect(typeof schema.pluginManifestSchema.parse).toBe("function");
|
||||
expect(typeof parse.parseManifest).toBe("function");
|
||||
expect(typeof parse.parseManifestSafe).toBe("function");
|
||||
expect(typeof validators.validateSagaOwnership).toBe("function");
|
||||
expect(typeof validators.validateOpenApiRequiresGraphqlOrRoutes).toBe(
|
||||
"function"
|
||||
);
|
||||
expect(typeof validators.validatePermissionsWhenSandboxed).toBe(
|
||||
"function"
|
||||
);
|
||||
expect(typeof validators.validateErrorStatusMapShape).toBe("function");
|
||||
expect(typeof depGraph.resolveInstallOrder).toBe("function");
|
||||
expect(typeof depGraph.satisfies).toBe("function");
|
||||
expect(typeof cap.resolveCapabilities).toBe("function");
|
||||
expect(typeof hash.hashManifest).toBe("function");
|
||||
expect(typeof hash.canonicalJson).toBe("function");
|
||||
expect(typeof errorCodes.MANIFEST_CODES).toBe("object");
|
||||
expect(typeof testing.runManifestConformance).toBe("function");
|
||||
expect(typeof testing.MINIMAL_FIXTURE).toBe("object");
|
||||
expect(typeof testing.MAXIMAL_FIXTURE).toBe("object");
|
||||
// root barrel
|
||||
expect(typeof root.parseManifest).toBe("function");
|
||||
expect(typeof root.MANIFEST_CODES).toBe("object");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user