UNPKG

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