Handle references into inactive modules
This commit is contained in:
40
tests/inactive-module-reference-test.mjs
Normal file
40
tests/inactive-module-reference-test.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { buildFindings, createFileRecord } from "../scripts/core/finding-engine.js";
|
||||
import { createFileLocator } from "../scripts/core/path-utils.js";
|
||||
|
||||
const files = [
|
||||
createFileRecord(createFileLocator("data", "modules/example-module/icons/token.webp"), 1234)
|
||||
];
|
||||
|
||||
const references = [
|
||||
{
|
||||
sourceType: "world-document",
|
||||
sourceScope: { ownerType: "world", ownerId: "demo-world", systemId: "demo-system", subtype: "actors" },
|
||||
sourceLabel: "Actor demo",
|
||||
normalized: {
|
||||
...createFileLocator("data", "modules/example-module/icons/token.webp"),
|
||||
targetKind: "local-file"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const packageActivity = {
|
||||
modules: new Map([["example-module", false]]),
|
||||
moduleLabels: new Map([["example-module", "Example Module"]])
|
||||
};
|
||||
|
||||
const result = buildFindings({ files, references, packageActivity, i18n: { format: (key, data={}) => `${key}:${data.modules ?? ""}` } });
|
||||
|
||||
assert.equal(
|
||||
result.findings.some(finding => finding.kind === "non-package-to-package-reference"),
|
||||
false,
|
||||
"world references into inactive modules should not be reported as unanchored package targets"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
result.notices.some(notice => notice.kind === "inactive-module-references" && notice.moduleIds.includes("example-module")),
|
||||
true,
|
||||
"inactive module references should create a report notice"
|
||||
);
|
||||
|
||||
console.log("inactive-module-reference-test: ok");
|
||||
Reference in New Issue
Block a user