|
1 | 1 | import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'; |
2 | 2 | import { PolkadotAgentKit } from '../../src/api'; |
| 3 | +import { getVercelAITools } from '../../src/vercel'; |
3 | 4 | import type { AgentConfig } from '@polkadot-agent-kit/common'; |
4 | 5 |
|
5 | 6 | const mockBalanceResult = { balance: '100.00', symbol: 'WND', chain: 'westend' }; |
@@ -58,6 +59,20 @@ vi.mock('../../src/api', () => { |
58 | 59 | mintVdotTool: vi.fn(() => ({ |
59 | 60 | call: vi.fn(async (input: any) => mockMintVdotResult) |
60 | 61 | })), |
| 62 | + getActions: vi.fn(() => [ |
| 63 | + { |
| 64 | + name: 'check_balance', |
| 65 | + description: 'Check balance of the wallet address on a specific chain', |
| 66 | + schema: {} as any, |
| 67 | + invoke: vi.fn(async (args: any) => JSON.stringify(mockBalanceResult)) |
| 68 | + }, |
| 69 | + { |
| 70 | + name: 'transfer_native', |
| 71 | + description: 'Transfer native tokens to an address', |
| 72 | + schema: {} as any, |
| 73 | + invoke: vi.fn(async (args: any) => JSON.stringify(mockTransferResult)) |
| 74 | + } |
| 75 | + ]), |
61 | 76 | disconnect: vi.fn().mockResolvedValue(undefined), |
62 | 77 | config: instanceConfig, |
63 | 78 | }; |
@@ -282,5 +297,27 @@ describe('PolkadotAgentKit E2E', () => { |
282 | 297 | assert(result); |
283 | 298 | }); |
284 | 299 | }); |
| 300 | + |
| 301 | + describe('getVercelAITools', () => { |
| 302 | + it('should return a toolset with correct structure', () => { |
| 303 | + const toolSet = getVercelAITools(agent); |
| 304 | + |
| 305 | + expect(toolSet).toBeDefined(); |
| 306 | + expect(typeof toolSet).toBe('object'); |
| 307 | + expect(toolSet.check_balance).toBeDefined(); |
| 308 | + expect(toolSet.transfer_native).toBeDefined(); |
| 309 | + |
| 310 | + // Check that the tools have the expected structure |
| 311 | + expect(typeof toolSet.check_balance.execute).toBe('function'); |
| 312 | + expect(typeof toolSet.transfer_native.execute).toBe('function'); |
| 313 | + }); |
| 314 | + |
| 315 | + it('should have tools with correct descriptions', () => { |
| 316 | + const toolSet = getVercelAITools(agent); |
| 317 | + |
| 318 | + expect(toolSet.check_balance.description).toBe('Check balance of the wallet address on a specific chain'); |
| 319 | + expect(toolSet.transfer_native.description).toBe('Transfer native tokens to an address'); |
| 320 | + }); |
| 321 | + }); |
285 | 322 | }); |
286 | 323 |
|
0 commit comments