test: tighten is-main helper coverage

This commit is contained in:
Peter Steinberger
2026-03-14 00:43:10 +00:00
parent 983fecc106
commit 958a2f31da

View File

@@ -24,6 +24,17 @@ describe("isMainModule", () => {
).toBe(true);
});
it("resolves relative pm_exec_path values against cwd", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.js",
argv: ["node", "/pm2/lib/ProcessContainerFork.js"],
cwd: "/repo",
env: { pm_exec_path: "./dist/index.js", pm_id: "0" },
}),
).toBe(true);
});
it("returns true for configured wrapper-to-entry pairs", () => {
expect(
isMainModule({
@@ -77,4 +88,15 @@ describe("isMainModule", () => {
}),
).toBe(true);
});
it("returns false when no entrypoint candidate exists", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.js",
argv: ["node"],
cwd: "/repo",
env: {},
}),
).toBe(false);
});
});