import type { IHttpClientImplementation } from '../ApiService'; import type { IExpectBuilder } from './expectedRequest'; import { ExpectedRequest } from './expectedRequest'; import type { IDeferred, UrlArg, Verb } from './mockHttpUtils'; import { ReceivedRequest } from './receivedRequest'; interface IRequest { verb: Verb; url: string; params: object; data: any; expected: boolean; responseDeferred: IDeferred; flushResponse: () => void; } /** * A mock HTTP client for unit tests. * * This class (and its counterparts) enables unit tests to expect that the code * being tested makes certain HTTP calls. When the code makes the expected HTTP * calls, the responses are deferred until the unit test calls .flush(). Then, * any pending responses are flushed. */ export declare class MockHttpClient implements IHttpClientImplementation { autoFlush: boolean; failOnUnexpectedRequests: boolean; expectedRequests: ExpectedRequest[]; receivedRequests: ReceivedRequest[]; private isFlushing; expect(verb: Verb, url?: UrlArg): IExpectBuilder; expectGET: (url?: UrlArg) => IExpectBuilder; expectPUT: (url?: UrlArg) => IExpectBuilder; expectPOST: (url?: UrlArg) => IExpectBuilder; expectDELETE: (url?: UrlArg) => IExpectBuilder; expectPATCH: (url?: UrlArg) => IExpectBuilder; request(verb: Verb, iRequest: IRequest): PromiseLike; get: (request: IRequest) => PromiseLike; put: (request: IRequest) => PromiseLike; post: (request: IRequest) => PromiseLike; patch: (request: IRequest) => PromiseLike; delete: (request: IRequest) => PromiseLike; private requestListeners; private addRequestListener; private needsFlush; /** * Waits until all expected requests are received. * This function is async and should be await'ed in the unit test. * * 1) Flushes the response data for all received requests. * The Promises in the code being tested will resolve or reject. * 2) Resolves when all expected requests have been fulfilled by a received request. * * If more requests are received during the wait period, they are also flushed. * * For interop with AngularJS code, the $httpBackend is also flushed * * @param timeoutMs: How long to wait for all the expected requests to be received. (default: 100) * @param delayAfterMs: How long to wait AFTER all the expected requests have been received (default: 0) */ flush({ timeoutMs, delayAfterMs }?: { timeoutMs?: number; delayAfterMs?: number; }): Promise; private getOutstandingExpectationMessages; verifyNoOutstandingExpectation(): void; verifyNoOutstandingRequests(): void; verifyNoUnexpectedRequests(): void; } export {};