mock-pool.d.ts 1.0 KB

123456789101112131415161718192021222324252627
  1. import Pool from './pool'
  2. import MockAgent from './mock-agent'
  3. import { Interceptable, MockInterceptor } from './mock-interceptor'
  4. import Dispatcher from './dispatcher'
  5. export default MockPool
  6. /** MockPool extends the Pool API and allows one to mock requests. */
  7. declare class MockPool extends Pool implements Interceptable {
  8. constructor (origin: string, options: MockPool.Options)
  9. /** Intercepts any matching requests that use the same origin as this mock pool. */
  10. intercept (options: MockInterceptor.Options): MockInterceptor
  11. /** Dispatches a mocked request. */
  12. dispatch (options: Dispatcher.DispatchOptions, handlers: Dispatcher.DispatchHandler): boolean
  13. /** Closes the mock pool 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 MockPool {
  19. /** MockPool options. */
  20. export interface Options extends Pool.Options {
  21. /** The agent to associate this MockPool with. */
  22. agent: MockAgent;
  23. }
  24. }