mock-client.d.ts 1.0 KB

123456789101112131415161718192021222324252627
  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.DispatchHandler): boolean
  13. /** Closes the mock client and gracefully waits for enqueued requests to complete. */
  14. close (): Promise<void>
  15. /** Clean up all the prepared mocks. */
  16. cleanMocks (): void
  17. }
  18. declare namespace MockClient {
  19. /** MockClient options. */
  20. export interface Options extends Client.Options {
  21. /** The agent to associate this MockClient with. */
  22. agent: MockAgent;
  23. }
  24. }