Update runtime checks and installer behavior
This commit is contained in:
35
tests/node-version.test.ts
Normal file
35
tests/node-version.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
MIN_NODE_VERSION,
|
||||
ensureSupportedNodeVersion,
|
||||
getUnsupportedNodeVersionLines,
|
||||
isSupportedNodeVersion,
|
||||
} from "../src/system/node-version.js";
|
||||
|
||||
test("isSupportedNodeVersion enforces the exact minimum floor", () => {
|
||||
assert.equal(isSupportedNodeVersion("20.18.1"), true);
|
||||
assert.equal(isSupportedNodeVersion("20.19.0"), true);
|
||||
assert.equal(isSupportedNodeVersion("21.0.0"), true);
|
||||
assert.equal(isSupportedNodeVersion("20.18.0"), false);
|
||||
assert.equal(isSupportedNodeVersion("18.17.0"), false);
|
||||
});
|
||||
|
||||
test("ensureSupportedNodeVersion throws a guided upgrade message", () => {
|
||||
assert.throws(
|
||||
() => ensureSupportedNodeVersion("18.17.0"),
|
||||
(error: unknown) =>
|
||||
error instanceof Error &&
|
||||
error.message.includes(`Node.js ${MIN_NODE_VERSION}`) &&
|
||||
error.message.includes("nvm install 20 && nvm use 20") &&
|
||||
error.message.includes("https://feynman.is/install"),
|
||||
);
|
||||
});
|
||||
|
||||
test("unsupported version guidance reports the detected version", () => {
|
||||
const lines = getUnsupportedNodeVersionLines("18.17.0");
|
||||
|
||||
assert.equal(lines[0], "feynman requires Node.js 20.18.1 or later (detected 18.17.0).");
|
||||
assert.ok(lines.some((line) => line.includes("curl -fsSL https://feynman.is/install | bash")));
|
||||
});
|
||||
@@ -41,6 +41,7 @@ test("buildPiEnv wires Feynman paths into the Pi environment", () => {
|
||||
assert.equal(env.FEYNMAN_SESSION_DIR, "/sessions");
|
||||
assert.equal(env.FEYNMAN_BIN_PATH, "/repo/feynman/bin/feynman.js");
|
||||
assert.equal(env.FEYNMAN_MEMORY_DIR, "/home/.feynman/memory");
|
||||
assert.ok(env.PATH?.startsWith("/repo/feynman/node_modules/.bin:/repo/feynman/.feynman/npm/node_modules/.bin:"));
|
||||
});
|
||||
|
||||
test("resolvePiPaths includes the Promise.withResolvers polyfill path", () => {
|
||||
|
||||
Reference in New Issue
Block a user