35 lines
1.6 KiB
JavaScript
35 lines
1.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "vitest";
|
|
|
|
import { getDeclaredBoundaryDependencies, isForbiddenBoundarySpecifier, isForbiddenRelativeBoundarySpecifier } from "./verify-phase-c-boundaries.mjs";
|
|
|
|
describe("verify-phase-c-boundaries", () => {
|
|
it("matches exact forbidden packages and their subpaths only", () => {
|
|
assert.equal(isForbiddenBoundarySpecifier("@toolctrl/db", "@toolctrl/db"), true);
|
|
assert.equal(isForbiddenBoundarySpecifier("@toolctrl/db/client.server", "@toolctrl/db"), true);
|
|
assert.equal(isForbiddenBoundarySpecifier("@toolctrl/database", "@toolctrl/db"), false);
|
|
assert.equal(isForbiddenBoundarySpecifier("react-dom", "react"), false);
|
|
});
|
|
|
|
it("matches relative imports that resolve into forbidden package roots", () => {
|
|
const rootDir = "/repo";
|
|
|
|
assert.equal(isForbiddenRelativeBoundarySpecifier("packages/ui-app/src/index.ts", "../../db/src/client.server", "@toolctrl/db", rootDir), true);
|
|
assert.equal(isForbiddenRelativeBoundarySpecifier("packages/ui-app/src/index.ts", "../view-models/src/index", "@toolctrl/db", rootDir), false);
|
|
assert.equal(isForbiddenRelativeBoundarySpecifier("packages/foundation/src/index.ts", "@toolctrl/db", "@toolctrl/db", rootDir), false);
|
|
});
|
|
|
|
it("includes devDependencies in package boundary dependency checks", () => {
|
|
assert.deepEqual(
|
|
getDeclaredBoundaryDependencies({
|
|
dependencies: { "@toolctrl/view-models": "workspace:*" },
|
|
devDependencies: { "@toolctrl/db": "workspace:*" },
|
|
}),
|
|
{
|
|
"@toolctrl/view-models": "workspace:*",
|
|
"@toolctrl/db": "workspace:*",
|
|
}
|
|
);
|
|
});
|
|
});
|