@ts-common/azure-js-dev-tools
Version:
Developer dependencies for TypeScript related projects
80 lines • 4.29 kB
TypeScript
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
/**
* A collection of additional assertion checks on top of the standard assert checks.
*/
export declare namespace assertEx {
/**
* Check that the provided text contains the provided substring.
* @param value The text to look in.
* @param substring The substring to look for.
*/
function contains(value: string | string[] | undefined, substring: string): void;
/**
* Check that the provided text contains the all of the provided substrings.
* @param value The text to look in.
* @param substrings The substring to look for.
*/
function containsAll(value: string | string[] | undefined, substrings: string[]): void;
/**
* Check that the provided text does not contain the provided substring.
* @param value The text to look in.
* @param substring The substring to look for.
*/
function doesNotContain(value: string | string[] | undefined, substring: string): void;
/**
* Check that the provided text doesn't contain any of the provided substrings.
* @param value The text to look in.
* @param substrings The substrings to look for.
*/
function doesNotContainAny(value: string | string[] | undefined, substrings: string[]): void;
/**
* Check that the two errors are equal (except for their stack property).
* @param actualError The actual error.
* @param expectedError The expected error.
* @param message The optional message to output if this check fails.
*/
function equalErrors(actualError: Error, expectedError: Error, message?: string): void;
/**
* Assert that the provided syncFunction throws an Error. If the expectedError is undefined, then
* this function will just assert that an Error was thrown. If the expectedError is defined, then
* this function will assert that the Error that was thrown is equal to the provided expectedError.
* @param syncFunction The synchronous function that is expected to thrown an Error.
* @param expectedError The Error that is expected to be thrown.
*/
function throws<TError extends Error>(syncFunction: () => void, expectedError?: ((error: TError) => void) | TError): TError;
/**
* Assert that the provided asyncFunction throws an Error. If the expectedError is undefined, then
* this function will just assert that an Error was thrown. If the expectedError is defined, then
* this function will assert that the Error that was thrown is equal to the provided expectedError.
* @param asyncFunction The asynchronous function that is expected to thrown an Error.
* @param expectedError The Error that is expected to be thrown.
*/
function throwsAsync<T, TError extends Error>(asyncFunction: (() => Promise<T>) | Promise<T>, expectedError?: ((error: TError) => void) | TError): Promise<TError>;
/**
* Assert that the provided value starts with the provided prefix.
* @param value The value to check.
* @param prefix The prefix to look for.
* @param expressionName The name of the expression that provided the value.
*/
function startsWith(value: string, prefix: string, expressionName?: string): void;
/**
* Assert that the provided value is defined. If it is, return the defined value.
* @param value The value to check.
* @param expressionName The name of the expression that provided the value.
*/
function defined<T>(value: T | undefined, expressionName?: string): T;
function definedAndNotEmpty(value: string | undefined, expressionName?: string): void;
function definedAndNotStrictEqual<T>(actualValue: T | undefined, expectedValue: T, expressionName?: string): void;
function greaterThan(value: number, expectedLowerBound: number, expressionName?: string): void;
/**
* Assert that the provided value is equal to one of the provided expectedValues.
* @param value The value to look for.
* @param expectedValues The expected values that value could be.
*/
function oneOf<T>(value: T, expectedValues: T[]): void;
}
//# sourceMappingURL=assertEx.d.ts.map