test(argv): cover root no-command detection

This commit is contained in:
Vincent Koc
2026-02-27 23:56:48 -08:00
parent e9ee68f9c5
commit 8a88b22e4d

View File

@@ -9,6 +9,7 @@ import {
hasHelpOrVersion,
hasFlag,
isRootHelpRequest,
isRootNoCommandRequest,
isRootVersionRequest,
shouldMigrateState,
shouldMigrateStateFromPath,
@@ -384,4 +385,29 @@ describe("argv helpers", () => {
])("isRootHelpRequest: $name", ({ argv, expected }) => {
expect(isRootHelpRequest(argv)).toBe(expected);
});
it.each([
{
name: "no args",
argv: ["node", "openclaw"],
expected: true,
},
{
name: "only root flags",
argv: ["node", "openclaw", "--dev", "--profile", "work"],
expected: true,
},
{
name: "subcommand present",
argv: ["node", "openclaw", "status"],
expected: false,
},
{
name: "non-flag token after terminator is ignored",
argv: ["node", "openclaw", "--", "status"],
expected: true,
},
])("isRootNoCommandRequest: $name", ({ argv, expected }) => {
expect(isRootNoCommandRequest(argv)).toBe(expected);
});
});