@contract-case/case-core
Version:
Core functionality for the ContractCase contract testing suite
75 lines • 3.48 kB
TypeScript
import { AnyMockDescriptorType } from '@contract-case/case-entities-internal';
import { MatchContext, CaseExample } from '@contract-case/case-plugin-base';
import { BaseCaseContract } from './BaseCaseContract';
import type { MultiTestInvoker } from './executeExample/types';
import type { CaseConfig } from './config/types';
import { ContractFileFromDisk, ContractVerificationResult, ContractVerificationTest, ReaderDependencies } from './types';
/**
* ReadingCaseContract deals with a single contract verification (read).
*
* It is the entry point for the actual verification process of a contract,
* but should be called from a connector. At the time of writing, the
* ContractVerifierConnector is the primary caller.
*
* @internal
*/
export declare class ReadingCaseContract extends BaseCaseContract {
private mutex;
private readonly makeBrokerService;
/**
* The verifier has its own copy of the contract,
* because some of the BaseCaseContract methods modify
* the contract.
*/
private readonly contractFileFromDisk;
/**
* What the verification status currently is.
*
* This is the true verification status; during a run it will be UNKNOWN
* if no current interactions have failed. It will be set to FAILED if
* any interaction fails.
*
* It can only be success once endRecord has been called.
*/
private status;
/**
* Indicates that the contract has been closed and verification is complete.
* Used to prevent attempts to calculate verification status twice.
*/
private contractClosed;
/**
* The tests passed back by a call to {@link ReadingCaseContract#getTests}
*
* Will be undefined if getTests has not been called.
*/
private verificationTests;
/**
* Constructs a ReadingCaseContract
*
* @param contractFile - The DownloadedContract to verify
* @param readerDependencies - The dependencies for a contract reader (injected)
* @param config - the CaseConfig for this run
* @param parentVersions - the array of versions of all the ContractCase packages before this one
*/
constructor(contractFile: ContractFileFromDisk, { resultFormatter: resultPrinter, makeLogger, defaultConfig, makeBrokerService, }: ReaderDependencies, config: CaseConfig, parentVersions: string[]);
/**
* Calls the executeExample function for a specific interaction.
*
* @param index - The index of the interaction to execute
* @param invoker - The invoker for this test
* @param completionCallback - A callback to be called before completing the example
* @returns A promise that resolves when the interaction has been executed completely
*/
callExecuteExample<T extends AnyMockDescriptorType>(index: number, invoker: MultiTestInvoker<T>, completionCallback?: () => void): Promise<void>;
/**
* Gets the tests that can be used later to verify the contract
*
* @param invoker - The invoker for this test
* @returns a list of {@link ContractVerificationTest}s that can be run later
* with the `runTest` callback on the ContractVerificationTest
*/
getTests<T extends AnyMockDescriptorType>(invoker: MultiTestInvoker<T>): ContractVerificationTest[];
recordExample(example: CaseExample, currentContext: MatchContext): CaseExample;
endRecord(): Promise<ContractVerificationResult>;
}
//# sourceMappingURL=ReadingCaseContract.d.ts.map