mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:00:43 +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);
|
||||
|
||||
@@ -397,7 +397,9 @@ describe("registerPluginCliCommands", () => {
|
||||
primary: "memory",
|
||||
});
|
||||
|
||||
expect(program.commands.filter((command) => command.name() === "memory")).toHaveLength(1);
|
||||
expect(
|
||||
program.commands.reduce((count, command) => count + (command.name() === "memory" ? 1 : 0), 0),
|
||||
).toBe(1);
|
||||
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["memory-core"],
|
||||
|
||||
Reference in New Issue
Block a user