mock-client.d.ts 1002 B

12345678910111213141516171819202122232425
  1. import Client from './client'
  2. import Dispatcher from './dispatcher'
  3. import MockAgent from './mock-agent'
  4. import { MockInterceptor, Interceptable } from './mock-interceptor'
  5. export default MockClient
  6. /** MockClient extends the Client API and allows one to mock requests. */
  7. declare class MockClient extends Client implements Interceptable {
  8. constructor(origin: string, options: MockClient.Options);
  9. /** Intercepts any matching requests that use the same origin as this mock client. */
  10. intercept(options: MockInterceptor.Options): MockInterceptor;
  11. /** Dispatches a mocked request. */
  12. dispatch(options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandlers): boolean;
  13. /** Closes the mock client and gracefully waits for enqueued requests to complete. */
  14. close(): Promise<void>;
  15. }
  16. declare namespace MockClient {
  17. /** MockClient options. */
  18. export interface Options extends Client.Options {
  19. /** The agent to associate this MockClient with. */
  20. agent: MockAgent;
  21. }
  22. }