import { PartialResponseForRequest } from './filtering/collection'; import { ComparatorFn } from './filtering/comparator'; import { Matcher } from './filtering/matcher'; import { ISerializedHttp, ISerializedRequest, ISerializedResponse, RequestSerializer } from './http-serializer'; import { RecordMode as Mode } from './recording'; export interface IInFlightRequest { startTime: number; requestSerializer: RequestSerializer; } export interface IResponseForMatchingRequest { response: PartialResponseForRequest; matcher: Matcher; } /** * Store the current execution context for YesNo by tracking requests & mocks. */ export default class Context { mode: Mode; /** * Completed serialized request-response objects. Used for: * A. Assertions * B. Saved to disk if in record mode */ interceptedRequestsCompleted: ISerializedHttp[]; /** * Serialized records loaded from disk. */ loadedMocks: ISerializedHttp[]; /** * Proxied requests which have not yet responded. When completed * the value is set to "null" but the index is preserved. */ inFlightRequests: Array; responsesForMatchingRequests: IResponseForMatchingRequest[]; comparatorFn: ComparatorFn; clear(): void; getMatchingMocks(matcher: Matcher): ISerializedHttp[]; getMatchingIntercepted(matcher: Matcher): ISerializedHttp[]; hasResponsesDefinedForMatchers(): boolean; addResponseForMatchingRequests(matchingResponse: IResponseForMatchingRequest): void; getResponseDefinedMatching(request: ISerializedRequest): ISerializedResponse | undefined; }