mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 11:09:34 +00:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
async function loadSubject() {
|
|
return import("./initial-navigation.ts");
|
|
}
|
|
|
|
test("uses cwd instead of session when both parameters are present", async () => {
|
|
const { getInitialNavigation } = await loadSubject();
|
|
const result = getInitialNavigation(new URLSearchParams({
|
|
cwd: " /work/project ",
|
|
session: "saved-session",
|
|
}));
|
|
|
|
assert.deepEqual(result, {
|
|
requestedCwd: "/work/project",
|
|
sessionId: null,
|
|
});
|
|
});
|
|
|
|
test("restores session when cwd is absent", async () => {
|
|
const { getInitialNavigation } = await loadSubject();
|
|
|
|
assert.deepEqual(
|
|
getInitialNavigation(new URLSearchParams({ session: "saved-session" })),
|
|
{ requestedCwd: null, sessionId: "saved-session" },
|
|
);
|
|
});
|
|
|
|
test("treats an empty cwd as absent", async () => {
|
|
const { getInitialNavigation } = await loadSubject();
|
|
|
|
assert.deepEqual(
|
|
getInitialNavigation(new URLSearchParams({ cwd: " ", session: "saved-session" })),
|
|
{ requestedCwd: null, sessionId: "saved-session" },
|
|
);
|
|
});
|
|
|
|
test("preserves a URL-encoded Windows path", async () => {
|
|
const { getInitialNavigation } = await loadSubject();
|
|
|
|
assert.deepEqual(
|
|
getInitialNavigation(new URLSearchParams("cwd=C%3A%5CProjects%5Cpi-web")),
|
|
{ requestedCwd: "C:\\Projects\\pi-web", sessionId: null },
|
|
);
|
|
});
|