49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
|
|
describe("purity", () => {
|
|
it("dist statically imports no browser or Node globals", {
|
|
timeout: 5000,
|
|
}, () => {
|
|
// This test is a compile-time/verification guard; the actual check is
|
|
// performed by the build process and the import graph.
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
it("dependency set is limited to the declared workspace deps and zod", {
|
|
timeout: 5000,
|
|
}, () => {
|
|
const pkg = require("../package.json");
|
|
const deps = Object.keys(pkg.dependencies ?? {});
|
|
const allowed = [
|
|
"@opentelemetry/api",
|
|
"@suaveplan/crypto-hash",
|
|
"@suaveplan/crypto-utils",
|
|
"@suaveplan/error",
|
|
"@suaveplan/mime",
|
|
"@suaveplan/types",
|
|
"tslib",
|
|
"zod",
|
|
];
|
|
for (const dep of deps) {
|
|
expect(allowed).toContain(dep);
|
|
}
|
|
});
|
|
|
|
it("importing the package mutates no global state", {
|
|
timeout: 5000,
|
|
}, async () => {
|
|
const before = new Set(Object.keys(globalThis));
|
|
await import("../src/index.js");
|
|
const after = new Set(Object.keys(globalThis));
|
|
const diff = [...after].filter((k) => !before.has(k));
|
|
// Zod registers __zod_globalRegistry and __zod_globalConfig on first use; both acceptable
|
|
const allowed = [
|
|
"__zod_globalRegistry",
|
|
"__zod_globalConfig",
|
|
"__VITEST_COVERAGE__",
|
|
];
|
|
const unexpected = diff.filter((k) => !allowed.includes(k));
|
|
expect(unexpected).toEqual([]);
|
|
});
|
|
});
|