import { IdpClientConstructor, IdpClientInstance } from "../../runtime/idp.mjs"; import { Mock } from "vitest"; //#region src/vitest/mocks/idp.d.ts type IdpMethod = keyof IdpClientInstance; type IdpResolver = (method: string, args: unknown[], namespace: string) => unknown; interface IdpCall { method: string; args: unknown[]; namespace: string; } /** Controls fallback behavior for IdP calls without a configured result. */ export interface MockIdpOptions { /** Return a type-compatible fixture or throw when no behavior is configured. */ onUnhandled?: "fallback" | "error"; } type IdpNamespaceMocks = { [Method in IdpMethod]: Mock; }; /** * Acquire a disposable mock for `tailor.idp`. Restored on dispose. * @param options - Controls behavior for calls without a configured result * @returns Disposable IDP mock control object * @example * ```typescript * import { mockIdp } from "@tailor-platform/sdk/vitest"; * * test("returns a user", async () => { * using idp = mockIdp(); * idp.namespace("my-idp").user.mockResolvedValue({ * id: "u-1", * name: "alice", * disabled: false, * mfaEnrolled: false, * mfaFactorIds: [], * }); * // … * }); * ``` */ export declare function mockIdp(options?: MockIdpOptions): { /** The mock IDP `Client` constructor (`vi.fn`). */ Client: Mock; namespace: (name: string) => IdpNamespaceMocks; setResolver(value: IdpResolver): void; /** * Enqueue a single result for the next IDP call. * The queue is shared across all methods and namespaces. * @param result - Result to return from the next IDP call */ enqueueResult(result: unknown): void; /** * Enqueue results for multiple subsequent IDP calls. * The queue is shared across all methods and namespaces. * @param results - Results to enqueue, one per upcoming call */ enqueueResults(...results: unknown[]): void; readonly calls: IdpCall[]; clear(): void; reset(): void; } & Disposable; //#endregion