Initial Commit
This commit is contained in:
51
packages/security-stack/security/hibp/src/index.test.ts
Normal file
51
packages/security-stack/security/hibp/src/index.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import * as pkg from "./index.js";
|
||||
|
||||
describe("public package surface", () => {
|
||||
it("every documented subpath export resolves", {
|
||||
timeout: 5000,
|
||||
}, async () => {
|
||||
await import("./range/range.js");
|
||||
await import("./range/range-mode.js");
|
||||
await import("./breach/breach-client.js");
|
||||
await import("./cache/cache.js");
|
||||
await import("./cache/lru.js");
|
||||
await import("./cache/null.js");
|
||||
await import("./client/client.js");
|
||||
await import("./client/options.schema.js");
|
||||
await import("./errors/codes.js");
|
||||
await import("./errors/hibp-error.js");
|
||||
await import("./schemas/breach.schema.js");
|
||||
await import("./schemas/paste.schema.js");
|
||||
await import("./schemas/pwned-result.schema.js");
|
||||
await import("./observability/metrics.js");
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it("root barrel uses explicit named re-exports", { timeout: 5000 }, () => {
|
||||
const indexPath = resolve(import.meta.dirname, "index.ts");
|
||||
const content = readFileSync(indexPath, "utf8");
|
||||
const exportStar = content
|
||||
.split("\n")
|
||||
.filter((l) => /^\s*export\s+\*\s+from\b/.test(l));
|
||||
// Allow namespace re-exports (`export * as ns from ...`) but not
|
||||
// bare `export * from ...`.
|
||||
expect(exportStar).toEqual([]);
|
||||
});
|
||||
|
||||
it("named exports include the documented surface", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
expect(typeof pkg.HibpClient).toBe("function");
|
||||
expect(typeof pkg.RangeClient).toBe("function");
|
||||
expect(typeof pkg.BreachClient).toBe("function");
|
||||
expect(typeof pkg.LruHibpCache).toBe("function");
|
||||
expect(typeof pkg.NullHibpCache).toBe("function");
|
||||
expect(typeof pkg.RateLimitGate).toBe("function");
|
||||
expect(typeof pkg.HibpError).toBe("function");
|
||||
expect(typeof pkg.HIBP_CODES).toBe("object");
|
||||
expect(typeof pkg.BreachSchema.parse).toBe("function");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user