Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc17f927

Browse files
committed
tweak api-helper tests
1 parentd84ee78 commitc17f927

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*asapiHelperfrom"./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-
constallAgents=extractAllAgents(workspaces);
169-
expect(allAgents.map((a)=>a.id)).toEqual(expectedIds);
143+
it("should extract agents from multiple workspaces",()=>{
144+
constworkspaces=[
145+
createWorkspaceWithAgents([
146+
createMockAgent({id:"agent1",name:"main"}),
147+
]),
148+
createWorkspaceWithAgents([
149+
createMockAgent({id:"agent2",name:"secondary"}),
150+
]),
151+
];
152+
153+
constagents=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+
constagents=apiHelper.extractAllAgents([]);
160+
expect(agents).toHaveLength(0);
161+
expect(agents).toEqual([]);
162+
});
163+
164+
it("should handle workspaces with no agents",()=>{
165+
constworkspaces=[createMockWorkspace(),createMockWorkspace()];
166+
constagents=apiHelper.extractAllAgents(workspaces);
167+
expect(agents).toHaveLength(0);
170168
});
171169
});
172170

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp