Skip to content

Commit c17f927

Browse files
committed
tweak api-helper tests
1 parent d84ee78 commit c17f927

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/api-helper.test.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { ErrorEvent } from "eventsource";
22
import { describe, expect, it } from "vitest";
3+
import * as apiHelper from "./api-helper";
34
import {
45
AgentMetadataEventSchema,
56
AgentMetadataEventSchemaArray,
67
errToStr,
78
extractAgents,
8-
extractAllAgents,
99
} from "./api-helper";
1010
import {
1111
createMockAgent,
@@ -140,33 +140,31 @@ describe("api-helper", () => {
140140
});
141141

142142
describe("extractAllAgents", () => {
143-
it.each([
144-
[
145-
"multiple workspaces with agents",
146-
[
147-
createWorkspaceWithAgents([{ id: "agent1", name: "main" }]),
148-
createWorkspaceWithAgents([{ id: "agent2", name: "secondary" }]),
149-
],
150-
["agent1", "agent2"],
151-
],
152-
["empty workspace list", [], []],
153-
[
154-
"mixed workspaces",
155-
[
156-
createWorkspaceWithAgents([{ id: "agent1", name: "main" }]),
157-
createMockWorkspace({
158-
latest_build: {
159-
...createMockWorkspace().latest_build,
160-
resources: [],
161-
},
162-
}),
163-
createWorkspaceWithAgents([{ id: "agent2", name: "secondary" }]),
164-
],
165-
["agent1", "agent2"],
166-
],
167-
])("should handle %s", (_, workspaces, expectedIds) => {
168-
const allAgents = extractAllAgents(workspaces);
169-
expect(allAgents.map((a) => a.id)).toEqual(expectedIds);
143+
it("should extract agents from multiple workspaces", () => {
144+
const workspaces = [
145+
createWorkspaceWithAgents([
146+
createMockAgent({ id: "agent1", name: "main" }),
147+
]),
148+
createWorkspaceWithAgents([
149+
createMockAgent({ id: "agent2", name: "secondary" }),
150+
]),
151+
];
152+
153+
const agents = apiHelper.extractAllAgents(workspaces);
154+
expect(agents).toHaveLength(2);
155+
expect(agents.map((a) => a.id)).toEqual(["agent1", "agent2"]);
156+
});
157+
158+
it("should handle empty workspaces array", () => {
159+
const agents = apiHelper.extractAllAgents([]);
160+
expect(agents).toHaveLength(0);
161+
expect(agents).toEqual([]);
162+
});
163+
164+
it("should handle workspaces with no agents", () => {
165+
const workspaces = [createMockWorkspace(), createMockWorkspace()];
166+
const agents = apiHelper.extractAllAgents(workspaces);
167+
expect(agents).toHaveLength(0);
170168
});
171169
});
172170

0 commit comments

Comments
 (0)