1 | import Router, { RemoveRouteOptions } from './Router.js';
|
2 | import { RouteName, UserRouteConfig, RouteResponse } from './Route.js';
|
3 | import { MatcherDefinition, RouteMatcher } from './Matchers.js';
|
4 | import CallHistory from './CallHistory.js';
|
5 | export type HardResetOptions = {
|
6 | includeSticky?: boolean;
|
7 | };
|
8 | export type FetchMockGlobalConfig = {
|
9 | includeContentLength?: boolean;
|
10 | matchPartialBody?: boolean;
|
11 | allowRelativeUrls?: boolean;
|
12 | };
|
13 | export type FetchImplementations = {
|
14 | fetch?: typeof fetch;
|
15 | Headers?: typeof Headers;
|
16 | Request?: typeof Request;
|
17 | Response?: typeof Response;
|
18 | };
|
19 | export type FetchMockConfig = FetchMockGlobalConfig & FetchImplementations;
|
20 | export declare const defaultFetchMockConfig: FetchMockConfig;
|
21 | export declare class FetchMock {
|
22 | config: FetchMockConfig;
|
23 | router: Router;
|
24 | callHistory: CallHistory;
|
25 | constructor(config: FetchMockConfig, router?: Router);
|
26 | createInstance(): FetchMock;
|
27 | fetchHandler(this: FetchMock, requestInput: string | URL | Request, requestInit?: RequestInit): Promise<Response>;
|
28 | route(matcher: UserRouteConfig): FetchMock;
|
29 | route(matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
30 | catch(response?: RouteResponse): FetchMock;
|
31 | defineMatcher(matcher: MatcherDefinition): void;
|
32 | removeRoutes(options?: RemoveRouteOptions): FetchMock;
|
33 | clearHistory(): FetchMock;
|
34 | mockGlobal(this: FetchMock): FetchMock;
|
35 | unmockGlobal(this: FetchMock): FetchMock;
|
36 | hardReset(options?: HardResetOptions): FetchMock;
|
37 | spy(this: FetchMock, matcher?: RouteMatcher | UserRouteConfig, name?: RouteName): FetchMock;
|
38 | spyGlobal(this: FetchMock): FetchMock;
|
39 | sticky: {
|
40 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
41 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
42 | };
|
43 | once: {
|
44 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
45 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
46 | };
|
47 | any: (this: FetchMock, response: RouteResponse, options?: UserRouteConfig | string) => FetchMock;
|
48 | anyOnce: (this: FetchMock, response: RouteResponse, options?: UserRouteConfig | string) => FetchMock;
|
49 | get: {
|
50 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
51 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
52 | };
|
53 | getOnce: {
|
54 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
55 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
56 | };
|
57 | post: {
|
58 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
59 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
60 | };
|
61 | postOnce: {
|
62 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
63 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
64 | };
|
65 | put: {
|
66 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
67 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
68 | };
|
69 | putOnce: {
|
70 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
71 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
72 | };
|
73 | delete: {
|
74 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
75 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
76 | };
|
77 | deleteOnce: {
|
78 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
79 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
80 | };
|
81 | head: {
|
82 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
83 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
84 | };
|
85 | headOnce: {
|
86 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
87 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
88 | };
|
89 | patch: {
|
90 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
91 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
92 | };
|
93 | patchOnce: {
|
94 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
95 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
96 | };
|
97 | }
|
98 | declare const fetchMock: FetchMock;
|
99 | export default fetchMock;
|