|
| 1 | +import assert from "node:assert/strict"; |
| 2 | +import { describe, it } from "node:test"; |
| 3 | + |
| 4 | +import { formatWorkingTooltip } from "./SidebarSection.tsx"; |
| 5 | + |
| 6 | +function summary(agentNames, agentCount = agentNames.length) { |
| 7 | + return { |
| 8 | + channelId: "chan-1", |
| 9 | + anchorAt: 0, |
| 10 | + agentCount, |
| 11 | + agentPubkeys: Array.from( |
| 12 | + { length: agentCount }, |
| 13 | + (_, index) => `agent-${index}-pubkey`, |
| 14 | + ), |
| 15 | + agentNames, |
| 16 | + }; |
| 17 | +} |
| 18 | + |
| 19 | +describe("formatWorkingTooltip", () => { |
| 20 | + it("names one known agent", () => { |
| 21 | + assert.equal(formatWorkingTooltip(summary(["Ned"])), "Ned working"); |
| 22 | + }); |
| 23 | + |
| 24 | + it("names one known agent and counts one additional agent", () => { |
| 25 | + assert.equal( |
| 26 | + formatWorkingTooltip(summary(["Ned", "Bart"])), |
| 27 | + "Ned and 1 agent working", |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it("names one known agent and counts multiple additional agents", () => { |
| 32 | + assert.equal( |
| 33 | + formatWorkingTooltip(summary(["Ned", "Bart", "Carl"])), |
| 34 | + "Ned and 2 agents working", |
| 35 | + ); |
| 36 | + }); |
| 37 | + |
| 38 | + it("uses a singular count when all agents are unknown", () => { |
| 39 | + assert.equal(formatWorkingTooltip(summary([], 1)), "1 agent working"); |
| 40 | + }); |
| 41 | + |
| 42 | + it("uses a plural count when all agents are unknown", () => { |
| 43 | + assert.equal(formatWorkingTooltip(summary([], 3)), "3 agents working"); |
| 44 | + }); |
| 45 | + |
| 46 | + it("counts unknown agents with the named lead", () => { |
| 47 | + assert.equal( |
| 48 | + formatWorkingTooltip(summary(["Ned"], 3)), |
| 49 | + "Ned and 2 agents working", |
| 50 | + ); |
| 51 | + }); |
| 52 | +}); |
0 commit comments