Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { vi } from 'vitest'; |
| 2 | import ComposioClient, { Auth } from '@composio/client'; |
| 3 | |
| 4 | const client = new ComposioClient({ auth: Auth.project('test-api-key') }); |
| 5 | |
| 6 | const tools = Object.assign(client.tools, { |
| 7 | list: vi.fn<typeof client.tools.list>(), |
| 8 | retrieve: vi.fn<typeof client.tools.retrieve>(), |
| 9 | execute: vi.fn<typeof client.tools.execute>(), |
| 10 | retrieveEnum: vi.fn<typeof client.tools.retrieveEnum>(), |
| 11 | getInput: vi.fn<typeof client.tools.getInput>(), |
| 12 | proxy: vi.fn<typeof client.tools.proxy>(), |
| 13 | }); |
| 14 | |
| 15 | const connectedAccounts = Object.assign(client.connectedAccounts, { |
| 16 | list: vi.fn<typeof client.connectedAccounts.list>(), |
| 17 | create: vi.fn<typeof client.connectedAccounts.create>(), |
| 18 | retrieve: vi.fn<typeof client.connectedAccounts.retrieve>(), |
| 19 | delete: vi.fn<typeof client.connectedAccounts.delete>(), |
| 20 | refresh: vi.fn<typeof client.connectedAccounts.refresh>(), |
| 21 | updateStatus: vi.fn<typeof client.connectedAccounts.updateStatus>(), |
| 22 | }); |
| 23 | |
| 24 | const toolkits = Object.assign(client.toolkits, { |
| 25 | list: vi.fn<typeof client.toolkits.list>(), |
| 26 | retrieve: vi.fn<typeof client.toolkits.retrieve>(), |
| 27 | retrieveCategories: vi.fn<typeof client.toolkits.retrieveCategories>(), |
| 28 | }); |
| 29 | |
| 30 | const authConfigs = Object.assign(client.authConfigs, { |
| 31 | list: vi.fn<typeof client.authConfigs.list>(), |
| 32 | create: vi.fn<typeof client.authConfigs.create>(), |
| 33 | retrieve: vi.fn<typeof client.authConfigs.retrieve>(), |
| 34 | update: vi.fn<typeof client.authConfigs.update>(), |
| 35 | delete: vi.fn<typeof client.authConfigs.delete>(), |
| 36 | updateStatus: vi.fn<typeof client.authConfigs.updateStatus>(), |
| 37 | }); |
| 38 | |
| 39 | const session = Object.assign(client.toolRouter.session, { |
| 40 | execute: vi.fn<typeof client.toolRouter.session.execute>(), |
| 41 | tools: vi.fn<typeof client.toolRouter.session.tools>(), |
| 42 | }); |
| 43 | const toolRouter = Object.assign(client.toolRouter, { session }); |
| 44 | const withOptions = vi.fn<typeof client.withOptions>(); |
| 45 | |
| 46 | export const mockClient = Object.assign(client, { |
| 47 | tools, |
| 48 | connectedAccounts, |
| 49 | toolkits, |
| 50 | authConfigs, |
| 51 | toolRouter, |
| 52 | withOptions, |
| 53 | }); |
| 54 | |
| 55 | withOptions.mockReturnValue(mockClient); |