test: avoid cli count filter allocations

This commit is contained in:
Peter Steinberger
2026-05-08 21:54:43 +01:00
parent 016c8c9968
commit 9803a96adc
3 changed files with 8 additions and 4 deletions

View File

@@ -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 () => {

View File

@@ -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);