1 | import Router, { RemoveRouteOptions } from './Router.js';
|
2 | import { RouteName, UserRouteConfig, RouteResponse, ModifyRouteConfig } 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 | removeRoute(routeName: string): FetchMock;
|
34 | modifyRoute(routeName: string, options: ModifyRouteConfig): this;
|
35 | clearHistory(): FetchMock;
|
36 | mockGlobal(this: FetchMock): FetchMock;
|
37 | unmockGlobal(this: FetchMock): FetchMock;
|
38 | hardReset(options?: HardResetOptions): FetchMock;
|
39 | spy(this: FetchMock, matcher?: RouteMatcher | UserRouteConfig, name?: RouteName): FetchMock;
|
40 | spyGlobal(this: FetchMock): FetchMock;
|
41 | sticky: {
|
42 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
43 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
44 | };
|
45 | once: {
|
46 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
47 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
48 | };
|
49 | any: (this: FetchMock, response: RouteResponse, options?: UserRouteConfig | string) => FetchMock;
|
50 | anyOnce: (this: FetchMock, response: RouteResponse, options?: UserRouteConfig | string) => FetchMock;
|
51 | get: {
|
52 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
53 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
54 | };
|
55 | getOnce: {
|
56 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
57 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
58 | };
|
59 | post: {
|
60 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
61 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
62 | };
|
63 | postOnce: {
|
64 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
65 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
66 | };
|
67 | put: {
|
68 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
69 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
70 | };
|
71 | putOnce: {
|
72 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
73 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
74 | };
|
75 | delete: {
|
76 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
77 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
78 | };
|
79 | deleteOnce: {
|
80 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
81 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
82 | };
|
83 | head: {
|
84 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
85 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
86 | };
|
87 | headOnce: {
|
88 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
89 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
90 | };
|
91 | patch: {
|
92 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
93 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
94 | };
|
95 | patchOnce: {
|
96 | (this: FetchMock, matcher: UserRouteConfig): FetchMock;
|
97 | (this: FetchMock, matcher: RouteMatcher, response: RouteResponse, options?: UserRouteConfig | string): FetchMock;
|
98 | };
|
99 | }
|
100 | declare const fetchMock: FetchMock;
|
101 | export default fetchMock;
|