UNPKG

2.07 kBTypeScriptView Raw
1export type MatcherFn<T> = (actualValue: T) => boolean;
2export declare class Matcher<T> {
3 readonly asymmetricMatch: MatcherFn<T>;
4 private readonly description;
5 $$typeof: symbol;
6 inverse?: boolean;
7 constructor(asymmetricMatch: MatcherFn<T>, description: string);
8 toString(): string;
9 toAsymmetricMatcher(): string;
10 getExpectedType(): string;
11}
12export declare class CaptorMatcher<T> {
13 $$typeof: symbol;
14 readonly asymmetricMatch: MatcherFn<T>;
15 readonly value: T;
16 readonly values: T[];
17 constructor();
18 getExpectedType(): string;
19 toString(): string;
20 toAsymmetricMatcher(): string;
21}
22export interface MatcherCreator<T, E = T> {
23 (expectedValue?: E): Matcher<T>;
24}
25export type MatchersOrLiterals<Y extends any[]> = {
26 [K in keyof Y]: Matcher<Y[K]> | Y[K];
27};
28export declare const any: MatcherCreator<any>;
29export declare const anyBoolean: MatcherCreator<boolean>;
30export declare const anyNumber: MatcherCreator<number>;
31export declare const anyString: MatcherCreator<string>;
32export declare const anyFunction: MatcherCreator<Function>;
33export declare const anySymbol: MatcherCreator<Symbol>;
34export declare const anyObject: MatcherCreator<any>;
35export declare const anyArray: MatcherCreator<any[]>;
36export declare const anyMap: MatcherCreator<Map<any, any>>;
37export declare const anySet: MatcherCreator<Set<any>>;
38export declare const isA: MatcherCreator<any>;
39export declare const arrayIncludes: MatcherCreator<any[], any>;
40export declare const setHas: MatcherCreator<Set<any>, any>;
41export declare const mapHas: MatcherCreator<Map<any, any>, any>;
42export declare const objectContainsKey: MatcherCreator<any, string>;
43export declare const objectContainsValue: MatcherCreator<any>;
44export declare const notNull: MatcherCreator<any>;
45export declare const notUndefined: MatcherCreator<any>;
46export declare const notEmpty: MatcherCreator<any>;
47export declare const captor: <T extends unknown = any>() => CaptorMatcher<T>;
48export declare const matches: <T extends unknown = any>(matcher: MatcherFn<T>) => Matcher<T>;