/
match.ts
30 lines (27 loc) · 1 KB
/
match.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Partial and special matching during assertions.
*/
export abstract class Match {
/**
* Matches the specified pattern with the array found in the same relative path of the target.
* The set of elements (or matchers) must be in the same order as would be found.
* @param pattern the pattern to match
*/
public static arrayWith(pattern: any[]): { [key: string]: any[] } {
return { $ArrayWith: pattern };
}
/**
* Matches the specified pattern to an object found in the same relative path of the target.
* The keys and their values (or matchers) must be present in the target but the target can be a superset.
* @param pattern the pattern to match
*/
public static objectLike(pattern: { [key: string]: any }): { [key: string]: { [key: string]: any } } {
return { $ObjectLike: pattern };
}
/**
* Matches targets according to a regular expression
*/
public static stringLikeRegexp(pattern: string): { [key: string]: string } {
return { $StringLike: pattern };
}
}