initial commit
This commit is contained in:
43
src/tmux.test.ts
Normal file
43
src/tmux.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
buildSplitWindowArgs,
|
||||
buildWrapperShellCommand,
|
||||
isInsideTmux,
|
||||
} from "./tmux.ts";
|
||||
|
||||
test("isInsideTmux reads the TMUX environment variable", () => {
|
||||
assert.equal(isInsideTmux({ TMUX: "/tmp/tmux-1000/default,123,0" } as NodeJS.ProcessEnv), true);
|
||||
assert.equal(isInsideTmux({} as NodeJS.ProcessEnv), false);
|
||||
});
|
||||
|
||||
test("buildWrapperShellCommand single-quotes paths safely", () => {
|
||||
const command = buildWrapperShellCommand({
|
||||
nodePath: "/usr/local/bin/node",
|
||||
wrapperPath: "/repo/tmux-subagent/src/wrapper/cli.mjs",
|
||||
metaPath: "/repo/.pi/subagents/runs/run-1/meta.json",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
command,
|
||||
"'/usr/local/bin/node' '/repo/tmux-subagent/src/wrapper/cli.mjs' '/repo/.pi/subagents/runs/run-1/meta.json'",
|
||||
);
|
||||
});
|
||||
|
||||
test("buildSplitWindowArgs targets the current window and cwd", () => {
|
||||
assert.deepEqual(buildSplitWindowArgs({
|
||||
windowId: "@7",
|
||||
cwd: "/repo",
|
||||
command: "'node' '/wrapper.mjs' '/meta.json'",
|
||||
}), [
|
||||
"split-window",
|
||||
"-P",
|
||||
"-F",
|
||||
"#{pane_id}",
|
||||
"-t",
|
||||
"@7",
|
||||
"-c",
|
||||
"/repo",
|
||||
"'node' '/wrapper.mjs' '/meta.json'",
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user