forked from heygen-com/hyperframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-workspace-contracts.test.mjs
More file actions
40 lines (36 loc) · 1.47 KB
/
Copy pathcheck-workspace-contracts.test.mjs
File metadata and controls
40 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import {
listWorkspaceContractIssues,
REQUIRED_WORKSPACE_SCRIPTS,
} from "./check-workspace-contracts.mjs";
describe("workspace contract checker", () => {
it("accepts workspaces with all executable lifecycle scripts", () => {
const scripts = Object.fromEntries(REQUIRED_WORKSPACE_SCRIPTS.map((name) => [name, "echo ok"]));
assert.deepEqual(listWorkspaceContractIssues("packages/example", { scripts }), []);
});
it("reports every missing or empty lifecycle script", () => {
assert.deepEqual(
listWorkspaceContractIssues("packages/example", { scripts: { build: " " } }),
REQUIRED_WORKSPACE_SCRIPTS.map(
(script) =>
`packages/example: missing executable \`${script}\` script or ` +
`hyperframesWorkspaceContract.${script} opt-out with a specific reason`,
),
);
});
it("accepts an explicit opt-out only when it has a specific reason", () => {
const pkg = {
scripts: { build: "build", typecheck: "typecheck" },
hyperframesWorkspaceContract: {
test: {
optOut: true,
reason: "Generated fixture validated by the owning package integration suite.",
},
},
};
assert.deepEqual(listWorkspaceContractIssues("packages/example", pkg), []);
pkg.hyperframesWorkspaceContract.test.reason = "no tests";
assert.equal(listWorkspaceContractIssues("packages/example", pkg).length, 1);
});
});