mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:10:44 +00:00
test: avoid cli count filter allocations
This commit is contained in:
@@ -173,8 +173,10 @@ describe("command-registry", () => {
|
||||
}
|
||||
|
||||
const names = namesOf(program);
|
||||
expect(names.filter((name) => name === "commitments")).toHaveLength(1);
|
||||
expect(names.filter((name) => name === "tasks")).toHaveLength(1);
|
||||
const countName = (target: string) =>
|
||||
names.reduce((count, name) => count + (name === target ? 1 : 0), 0);
|
||||
expect(countName("commitments")).toBe(1);
|
||||
expect(countName("tasks")).toBe(1);
|
||||
});
|
||||
|
||||
it("replaces placeholders when loading a grouped entry by secondary command name", async () => {
|
||||
|
||||
@@ -192,7 +192,7 @@ describe("registerSubCliCommands", () => {
|
||||
await registerSubCliByName(program, "acp");
|
||||
|
||||
const names = program.commands.map((cmd) => cmd.name());
|
||||
expect(names.filter((name) => name === "acp")).toHaveLength(1);
|
||||
expect(names.reduce((count, name) => count + (name === "acp" ? 1 : 0), 0)).toBe(1);
|
||||
|
||||
await program.parseAsync(["acp"], { from: "user" });
|
||||
expect(registerAcpCli).toHaveBeenCalledTimes(1);
|
||||
|
||||
Reference in New Issue
Block a user