Initial Commit
This commit is contained in:
24
packages/api-stack/api/api-sse/tests/dep-graph.test.ts
Normal file
24
packages/api-stack/api/api-sse/tests/dep-graph.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const pkg = JSON.parse(
|
||||
readFileSync(join(__dirname, "..", "package.json"), "utf8")
|
||||
);
|
||||
|
||||
describe("@suaveplan/api-sse dep-graph", () => {
|
||||
it("depends only on api-types, error, types, tslib, zod", () => {
|
||||
const deps = Object.keys(pkg.dependencies ?? {}).sort();
|
||||
expect(deps).toEqual(
|
||||
["@suaveplan/api-types", "@suaveplan/error", "tslib", "zod"].sort()
|
||||
);
|
||||
}, 5000);
|
||||
|
||||
it("declares no runtime peer dependencies", () => {
|
||||
expect(pkg.peerDependencies ?? {}).toEqual({});
|
||||
}, 5000);
|
||||
|
||||
it("ships sideEffects: false", () => {
|
||||
expect(pkg.sideEffects).toBe(false);
|
||||
}, 5000);
|
||||
});
|
||||
40
packages/api-stack/api/api-sse/tests/zod-import-form.test.ts
Normal file
40
packages/api-stack/api/api-sse/tests/zod-import-form.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Pins the `import z from "zod"` convention across this package.
|
||||
*
|
||||
* Any file that imports zod via the named form
|
||||
* (`import { z } from "zod"`) breaks under Bun and is forbidden by
|
||||
* memory-rule `feedback_zod_import.md`. This test scans every
|
||||
* `src/**` file and fails on any non-default import.
|
||||
*/
|
||||
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const SRC = join(__dirname, "..", "src");
|
||||
|
||||
function walk(dir: string, out: string[] = []): string[] {
|
||||
for (const entry of readdirSync(dir)) {
|
||||
const full = join(dir, entry);
|
||||
const stat = statSync(full);
|
||||
if (stat.isDirectory()) {
|
||||
walk(full, out);
|
||||
} else if (full.endsWith(".ts")) {
|
||||
out.push(full);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("zod import form", () => {
|
||||
it("every src file uses default-import z", () => {
|
||||
const offenders: string[] = [];
|
||||
for (const file of walk(SRC)) {
|
||||
const text = readFileSync(file, "utf8");
|
||||
if (/import\s*\{\s*z[ ,}]/.test(text)) {
|
||||
offenders.push(file);
|
||||
}
|
||||
}
|
||||
expect(offenders).toEqual([]);
|
||||
}, 5000);
|
||||
});
|
||||
Reference in New Issue
Block a user