mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten topology record assertions
This commit is contained in:
@@ -34,11 +34,20 @@ function deriveReportEnvelope(report: Parameters<typeof filterRecordsForReport>[
|
||||
const singleOwnerEnvelope = deriveReportEnvelope("single-owner-shared");
|
||||
const unusedEnvelope = deriveReportEnvelope("unused-public-surface");
|
||||
|
||||
function requireRecordByExport(exportName: string) {
|
||||
const record = publicSurfaceEnvelope.records.find((entry) =>
|
||||
entry.exportNames.includes(exportName),
|
||||
);
|
||||
expect(record).toBeDefined();
|
||||
if (!record) {
|
||||
throw new Error(`Expected topology record for ${exportName}`);
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
describe("ts-topology", () => {
|
||||
it("collapses canonical symbols exported by multiple public subpaths", () => {
|
||||
const sharedThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("sharedThing"),
|
||||
);
|
||||
const sharedThing = requireRecordByExport("sharedThing");
|
||||
|
||||
expect(sharedThing).toMatchObject({
|
||||
declarationPath: "src/lib/shared.ts",
|
||||
@@ -47,21 +56,15 @@ describe("ts-topology", () => {
|
||||
productionPackages: ["src"],
|
||||
productionOwners: ["extension:alpha", "extension:beta", "src"],
|
||||
});
|
||||
expect(sharedThing?.publicSpecifiers).toEqual(["fixture-sdk", "fixture-sdk/extra"]);
|
||||
expect(sharedThing.publicSpecifiers).toEqual(["fixture-sdk", "fixture-sdk/extra"]);
|
||||
});
|
||||
|
||||
it("counts renamed imports, namespace imports, type-only imports, and test-only consumers", () => {
|
||||
const aliasedThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("aliasedThing"),
|
||||
);
|
||||
const sharedType = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("SharedType"),
|
||||
);
|
||||
const testOnlyThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("testOnlyThing"),
|
||||
);
|
||||
const aliasedThing = requireRecordByExport("aliasedThing");
|
||||
const sharedType = requireRecordByExport("SharedType");
|
||||
const testOnlyThing = requireRecordByExport("testOnlyThing");
|
||||
|
||||
expect(aliasedThing?.productionRefCount).toBe(1);
|
||||
expect(aliasedThing.productionRefCount).toBe(1);
|
||||
expect(sharedType).toMatchObject({
|
||||
isTypeOnlyCandidate: true,
|
||||
productionExtensions: ["alpha", "beta"],
|
||||
|
||||
Reference in New Issue
Block a user