Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions __tests__/agent-profile-data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { describe, expect, it } from "vitest"
import { createAgents } from "@/lib/data"
import {
formatAgentJoinedDate,
getAgentBadgeShowcase,
getAgentGlobalRank,
getAgentJoinedDate,
getAgentPassportStatus,
getAgentPrimaryMarketplaceHref,
getAgentProfileServices,
getAgentRecentActivity,
getAgentXpHistory,
} from "@/lib/agent-profile-data"
import { getAgentCardStats } from "@/lib/og-card-data"

describe("agent profile data helpers", () => {
it("returns deterministic rank and joined date display values", () => {
const agents = createAgents()
const [agent] = agents

expect(getAgentGlobalRank(agent, agents)).toBeGreaterThanOrEqual(1)
expect(getAgentGlobalRank(agent, agents)).toBeLessThanOrEqual(agents.length)
expect(formatAgentJoinedDate(getAgentJoinedDate(agent))).toBe("June 2026")
})

it("builds badge, service, activity, and passport sections for a profile", () => {
const [agent] = createAgents()

expect(getAgentBadgeShowcase(agent)).toHaveLength(6)
expect(getAgentProfileServices(agent).length).toBeGreaterThan(0)
expect(getAgentPrimaryMarketplaceHref(agent)).toMatch(/^\/marketplace/)
expect(getAgentRecentActivity(agent)).toHaveLength(4)
expect(getAgentPassportStatus(agent)).toMatchObject({
verified: true,
network: "Stellar mainnet",
})
})

it("generates a 30 day XP history ending at the current profile level", () => {
const [agent] = createAgents()
const history = getAgentXpHistory(agent)
const stats = getAgentCardStats(agent)

expect(history).toHaveLength(30)
expect(history[0].level).toBeLessThanOrEqual(history[history.length - 1].level)
expect(history[history.length - 1].level).toBe(stats.level)
})
})
Loading
Loading