@selfage/test_matcher
Version:
A pattern to match actual value with expected in tests.
24 lines (23 loc) • 1.72 kB
TypeScript
export declare function assert(tested: boolean, expected: string, actual: string): void;
export declare function assertReject(promise: Promise<any>): Promise<any>;
export declare function assertThrow(method: () => void): any;
export type AsyncMatchFn<T> = (actual: T) => Promise<void>;
export declare function asyncAssertThat<T>(actual: T, asyncMatch: AsyncMatchFn<T>, targetName: string): Promise<void>;
export type MatchFn<T> = (actual: T) => void;
export declare function assertThat<T>(actual: T, match: MatchFn<T>, targetName: string): void;
export declare function any<T>(): MatchFn<T>;
export declare function eq<T>(expected: T): MatchFn<T>;
export declare function ne<T>(expected: T): MatchFn<T>;
export declare function eqLongStr(expected: string): MatchFn<string>;
export declare function gt(expected: number): MatchFn<number>;
export declare function ge(expected: number): MatchFn<number>;
export declare function lt(expected: number): MatchFn<number>;
export declare function le(expected: number): MatchFn<number>;
export declare function eqAppr(expected: number, deviation?: number): MatchFn<number>;
export declare function containStr(expected: string): MatchFn<string>;
export declare function isArray<T>(expected?: Array<MatchFn<T>>): MatchFn<Array<T>>;
export declare function containUnorderedElements<T>(expectedMatchers?: Array<MatchFn<T>>): MatchFn<Array<T>>;
export declare function isUnorderedArray<T>(expected?: Array<MatchFn<T>>): MatchFn<Array<T>>;
export declare function isSet<T>(expected?: Array<MatchFn<T>>): MatchFn<Set<T>>;
export declare function isMap<K, V>(expected?: Array<[MatchFn<K>, MatchFn<V>]>): MatchFn<Map<K, V>>;
export declare function eqError(expected: Error): MatchFn<any>;