import type { IConnectionFacade, DescribeSObjectResult, ExecuteAnonymousResult } from '../connection-facade.js'; import type { CallRecord, MockConnectionConfig } from './types.js'; /** * Mock connection facade with call recording. * * @example * ```typescript * const { connection, calls, setQueryResult, setError } = createMockConnection(); * * // Configure response * setQueryResult('SELECT Id FROM Account', { * done: true, * totalSize: 1, * records: [{ Id: '001xx000001ABC' }] * }); * * // Use in adapter * const adapter = new SoqlQueryAdapter(connection); * const result = await adapter.query('SELECT Id FROM Account'); * * // Assert calls were made * expect(calls).to.have.lengthOf(1); * expect(calls[0].method).to.equal('query'); * ``` */ export type MockConnectionFacade = { /** The mock connection instance */ connection: IConnectionFacade; /** Recorded method calls */ calls: CallRecord[]; /** Reset call history */ resetCalls(): void; /** Set a query result for a specific SOQL query */ setQueryResult(soql: string, result: unknown): void; /** Set a describe result for a specific object */ setDescribeResult(objectName: string, result: DescribeSObjectResult): void; /** Set an error for a specific method call (returns error via checkError) */ setError(method: string, key: string, error: Error): void; /** Set the identity result */ setIdentity(identity: { user_id: string; organization_id: string; username: string; }): void; /** Set an execute anonymous result */ setExecuteAnonymousResult(apex: string, result: ExecuteAnonymousResult): void; /** Set a request result for a specific URL */ setRequestResult(url: string, result: unknown): void; /** * Set an exception to throw for a specific method/key combination. * Unlike setError (which throws via checkError internally), setThrow allows * testing of code that catches exceptions at a higher level. */ setThrow(method: string, key: string, error: Error): void; /** Clear a previously configured exception */ clearThrow(method: string, key: string): void; }; /** * Creates a mock connection facade for testing adapters. * * @param config - Optional configuration * @returns Mock connection facade with call recording * * @example * ```typescript * // Basic usage * const { connection } = createMockConnection(); * const adapter = new SoqlQueryAdapter(connection); * * // With configuration * const { connection, calls } = createMockConnection({ * version: '58.0', * defaultQueryResult: { done: true, totalSize: 0, records: [] } * }); * ``` */ export declare function createMockConnection(config?: MockConnectionConfig): MockConnectionFacade;