import sinon from 'sinon'; import type { ISoqlQueryAdapter } from '../soql/soql-query-adapter.js'; /** * Named sinon stubs for a stub-backed ISoqlQueryAdapter. * * Use the individual stubs to configure call behaviour directly with sinon's * `.resolves()`, `.rejects()`, `.onFirstCall()`, etc. — no `as unknown as` * cast is required because the `adapter` property satisfies ISoqlQueryAdapter. * * @example * ```typescript * const stubSoql = createStubSoqlAdapter(); * stubSoql.queryStub.resolves(createSuccessResult({ done: true, totalSize: 1, records: [{ Id: '001' }] })); * const service = new MyService(stubSoql.adapter); * ``` */ export type StubSoqlAdapter = { /** The fully-typed ISoqlQueryAdapter backed by sinon stubs */ adapter: ISoqlQueryAdapter; /** Stub for adapter.query */ queryStub: sinon.SinonStub; /** Stub for adapter.queryAll */ queryAllStub: sinon.SinonStub; /** Stub for adapter.queryChunked */ queryChunkedStub: sinon.SinonStub; }; /** * Creates a fully-typed ISoqlQueryAdapter backed by sinon stubs. * * All methods required by ISoqlQueryAdapter are provided as sinon stubs, * so TypeScript accepts the return value without any type cast. * * Prefer this factory over hand-rolling `{ query: sinon.stub(), queryAll: sinon.stub(), queryChunked: sinon.stub() }` * partial objects in service unit tests. * * @returns StubSoqlAdapter containing the adapter and all underlying stubs * * @example * ```typescript * import { createStubSoqlAdapter, type StubSoqlAdapter } from '../../../src/adapters/testing/index.js'; * * let stubSoql: StubSoqlAdapter; * * beforeEach(() => { * stubSoql = createStubSoqlAdapter(); * service = new ProfilingDefinitionService(stubSoql.adapter, mockApexAdapter); * }); * * it('queries definitions', async () => { * stubSoql.queryStub.resolves(createSuccessResult({ done: true, totalSize: 0, records: [] })); * const result = await service.getAll(); * expect(result.success).to.equal(true); * }); * ``` */ export declare function createStubSoqlAdapter(): StubSoqlAdapter;