Initial Commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const PKG_ROOT = path.resolve(import.meta.dirname, "..");
|
||||
|
||||
describe("api-tenant-resolver-subdomain — dependency graph and exports map", () => {
|
||||
it("exports map advertises every feature subpath", {
|
||||
timeout: 5000,
|
||||
}, async () => {
|
||||
const raw = await readFile(path.join(PKG_ROOT, "package.json"), "utf8");
|
||||
const pkg = JSON.parse(raw) as {
|
||||
exports: Record<string, unknown>;
|
||||
};
|
||||
const subpaths = Object.keys(pkg.exports)
|
||||
.filter(
|
||||
(k) =>
|
||||
(k === "." || k.startsWith("./")) && k !== "./package.json"
|
||||
)
|
||||
.sort();
|
||||
expect(subpaths).toEqual(
|
||||
[
|
||||
".",
|
||||
"./resolver",
|
||||
"./forwarded",
|
||||
"./validate",
|
||||
"./options",
|
||||
"./error-codes",
|
||||
"./otel",
|
||||
].sort()
|
||||
);
|
||||
});
|
||||
|
||||
it("dependencies use only workspace and catalog refs", {
|
||||
timeout: 5000,
|
||||
}, async () => {
|
||||
const raw = await readFile(path.join(PKG_ROOT, "package.json"), "utf8");
|
||||
const pkg = JSON.parse(raw) as {
|
||||
dependencies?: Record<string, string>;
|
||||
devDependencies?: Record<string, string>;
|
||||
};
|
||||
const all = {
|
||||
...(pkg.dependencies ?? {}),
|
||||
...(pkg.devDependencies ?? {}),
|
||||
};
|
||||
for (const [name, version] of Object.entries(all)) {
|
||||
if (name === "@opentelemetry/sdk-metrics") continue;
|
||||
if (
|
||||
!version.startsWith("workspace:") &&
|
||||
!version.startsWith("catalog:")
|
||||
) {
|
||||
throw new Error(
|
||||
`Dependency ${name} uses bare version '${version}' — must be workspace:/catalog:`
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user