import type { UrlArg, Verb } from './mockHttpUtils'; import type { ReceivedRequest } from './receivedRequest'; /** * This class represents an HTTP request that is expected to be made by the code under test. * Instances are created by MockHttpClient.expect -- this class should not be used directly. * * This class exposes a promise (this.fulfilledDeferred.promise). * The promise will be resolved when the code under test makes the expected HTTP request. * * ExpectedRequest also stores the (optional) mock response status/data to return to the code under test. */ export declare class ExpectedRequest implements IExpectBuilder { verb: Verb; urlArg: UrlArg; path: string; expectedParams: {}; exactParams: boolean; onResponseReceivedCallback: (request: ReceivedRequest) => void; /** * Creates a new ExpectRequest object * @param verb GET/PUT/POST/DELETE * @param urlArg the URL to match: string, regexp, or matcher * If a string, query params are parsed out of the string and used as a partial match against each request * e.g.: '/foo/bar?param1=val1¶m2=val2' */ constructor(verb: Verb, urlArg?: UrlArg); response: { status: number; data: any; }; isFulfilled: () => boolean; fulfilledDeferred: import("./mockHttpUtils").IDeferred; /** * Marks the expected response as fulfilled and settles the promise using the mock response. */ fulfill(): void; isMatchAndUnfulfilled(verb: Verb, url: string, params: object): boolean; matchVerb: (verb: Verb) => boolean; matchUrl: (requestUrl: string) => boolean; matchParams: (requestParams: object) => boolean; onRequestReceived(callback: (request: ReceivedRequest) => void): this; withParams(expectedParams: {}, exact?: boolean): IExpectBuilder; respond(status: number, data?: any): IExpectBuilder; } export interface IExpectBuilder { /** * This callback is invoked when the expected request is received * @param callback The callback to invoke. * The callback receives the ReceivedRequest object */ onRequestReceived(callback: (request: ReceivedRequest) => void): IExpectBuilder; /** * Match only requests with the expected query parameters * @param expectedParams the required params to match * @param exact match exact params * false: (default) actual params must include expected params * true: actual params exactly match expected params */ withParams(expectedParams: {}, exact?: boolean): IExpectBuilder; /** * Set the response for the expected request * @param status the HTTP status code * - For 2xx status codes, resolves the promise. * - For other status codes, rejects the promise * @param data the response payload */ respond(status: number, data?: any): IExpectBuilder; }