路泰科技体检小程序UI设计新版本
qx
2025-08-06 fe97f78b9a343ee9fa45a3531d03d73dcd1df31b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import Agent from './agent'
import Dispatcher from './dispatcher'
import { Interceptable, MockInterceptor } from './mock-interceptor'
import MockDispatch = MockInterceptor.MockDispatch
import { MockCallHistory } from './mock-call-history'
 
export default MockAgent
 
interface PendingInterceptor extends MockDispatch {
  origin: string;
}
 
/** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */
declare class MockAgent<TMockAgentOptions extends MockAgent.Options = MockAgent.Options> extends Dispatcher {
  constructor (options?: TMockAgentOptions)
  /** 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. */
  get<TInterceptable extends Interceptable>(origin: string): TInterceptable
  get<TInterceptable extends Interceptable>(origin: RegExp): TInterceptable
  get<TInterceptable extends Interceptable>(origin: ((origin: string) => boolean)): TInterceptable
  /** Dispatches a mocked request. */
  dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
  /** Closes the mock agent and waits for registered mock pools and clients to also close before resolving. */
  close (): Promise<void>
  /** Disables mocking in MockAgent. */
  deactivate (): void
  /** 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. */
  activate (): void
  /** Define host matchers so only matching requests that aren't intercepted by the mock dispatchers will be attempted. */
  enableNetConnect (): void
  enableNetConnect (host: string): void
  enableNetConnect (host: RegExp): void
  enableNetConnect (host: ((host: string) => boolean)): void
  /** Causes all requests to throw when requests are not matched in a MockAgent intercept. */
  disableNetConnect (): void
  /** get call history. returns the MockAgent call history or undefined if the option is not enabled. */
  getCallHistory (): MockCallHistory | undefined
  /** clear every call history. Any MockCallHistoryLog will be deleted on the MockCallHistory instance */
  clearCallHistory (): void
  /** Enable call history. Any subsequence calls will then be registered. */
  enableCallHistory (): this
  /** Disable call history. Any subsequence calls will then not be registered. */
  disableCallHistory (): this
  pendingInterceptors (): PendingInterceptor[]
  assertNoPendingInterceptors (options?: {
    pendingInterceptorsFormatter?: PendingInterceptorsFormatter;
  }): void
}
 
interface PendingInterceptorsFormatter {
  format(pendingInterceptors: readonly PendingInterceptor[]): string;
}
 
declare namespace MockAgent {
  /** MockAgent options. */
  export interface Options extends Agent.Options {
    /** A custom agent to be encapsulated by the MockAgent. */
    agent?: Dispatcher;
 
    /** Ignore trailing slashes in the path */
    ignoreTrailingSlash?: boolean;
 
    /** Enable call history. you can either call MockAgent.enableCallHistory(). default false */
    enableCallHistory?: boolean
  }
}