import { HttpMethod } from './models/http-method.js'; import { InitConfig } from './models/init-config.js'; import { ParamMatcher, ParamType } from './models/parameter-type.js'; import { RouteResponseCallback } from './models/route-response-callback.js'; import { StubHandle } from './models/stub-handle.js'; export declare class EasyNetworkStub { private readonly _urlMatch; private readonly _config; /** * A class to intercept and stub all calls to a certain api path. * @param urlMatch The match for all request urls that should be intercepted. * All non-stubbed calls that match this interceptor will throw an error */ constructor(urlMatch: string | RegExp); private addDefaultParamTypes; /** * Call this in your beforeEach hook to start using the stub. */ protected initInternal(config: InitConfig): T; /** * Add a new parameter type that can be used in the stub method route property. * @param name The name of the new parameter (To use it as {name} later in the route property) * @param matcher The regex matching group that matches the parameter. Eg: "([a-z]\d+)" * @param parser The optional function that parses the string found by the matcher into any type you want. */ addParameterType(name: string, matcher: ParamMatcher, type: ParamType, parser?: (v: string) => any): void; /** * Add a single api stub to your intercepted routes. * @param method The http method that should be stubbed * @param route The route that should be stubbed. Supports parameters in the form of {name:type}. * @param response The callback in which you can process the request and reply with the stub. When a Promise is returned, the stub response will be delayed until it is resolved. */ stub(method: HttpMethod, route: Route, response: RouteResponseCallback): StubHandle; /** * The stub2 method provides a way to set the type of the body that is sent. * Due to restrictions in TypeScript (https://github.com/microsoft/TypeScript/issues/10571, https://github.com/Microsoft/TypeScript/pull/26349), * We have to hacke a bit here. Calling stub2() will return the stub method with a body of type T. * * Usage: * ``` * .stub2()('GET', '/api/test', ({ body }) => { * // body is of type MyRequest * }); * ``` * @returns The stub method with a body of type T. */ stub2(): (method: HttpMethod, route: Route, response: RouteResponseCallback) => StubHandle; unregisterAll(): void; }