source: imaps-frontend/node_modules/undici-types/mock-agent.d.ts

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.5 KB
Line 
1import Agent from './agent'
2import Dispatcher from './dispatcher'
3import { Interceptable, MockInterceptor } from './mock-interceptor'
4import MockDispatch = MockInterceptor.MockDispatch;
5
6export default MockAgent
7
8interface PendingInterceptor extends MockDispatch {
9 origin: string;
10}
11
12/** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */
13declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.Options> extends Dispatcher {
14 constructor(options?: MockAgent.Options)
15 /** Creates and retrieves mock Dispatcher instances which can then be used to intercept HTTP requests. If the number of connections on the mock agent is set to 1, a MockClient instance is returned. Otherwise a MockPool instance is returned. */
16 get<TInterceptable extends Interceptable>(origin: string): TInterceptable;
17 get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable;
18 get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable;
19 /** Dispatches a mocked request. */
20 dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
21 /** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
22 close(): Promise<void>;
23 /** Disables mocking in MockAgent. */
24 deactivate(): void;
25 /** Enables mocking in a MockAgent instance. When instantiated, a MockAgent is automatically activated. Therefore, this method is only effective after `MockAgent.deactivate` has been called. */
26 activate(): void;
27 /** Define host matchers so only matching requests that aren't intercepted by the mock dispatchers will be attempted. */
28 enableNetConnect(): void;
29 enableNetConnect(host: string): void;
30 enableNetConnect(host: RegExp): void;
31 enableNetConnect(host: ((host: string) => boolean)): void;
32 /** Causes all requests to throw when requests are not matched in a MockAgent intercept. */
33 disableNetConnect(): void;
34 pendingInterceptors(): PendingInterceptor[];
35 assertNoPendingInterceptors(options?: {
36 pendingInterceptorsFormatter?: PendingInterceptorsFormatter;
37 }): void;
38}
39
40interface PendingInterceptorsFormatter {
41 format(pendingInterceptors: readonly PendingInterceptor[]): string;
42}
43
44declare namespace MockAgent {
45 /** MockAgent options. */
46 export interface Options extends Agent.Options {
47 /** A custom agent to be encapsulated by the MockAgent. */
48 agent?: Agent;
49 }
50}
Note: See TracBrowser for help on using the repository browser.