forked from testdouble/testdouble.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
72 lines (53 loc) · 1.7 KB
/
index.d.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
export type TestDouble = Function;
export type DoubledObjectWithKey<Key extends string> = {};
export type DoubledObject<Subject> = Subject;
declare function functionDouble(name?: string): TestDouble;
export { functionDouble as function };
// When passed class or constructor function
export function object<T>(constructor: { new (...args: any[]): T }): DoubledObject<T>;
// When passed array of props
export function object<Key extends string>(props: Key[]): DoubledObjectWithKey<Key>;
// When passed general object
export function object<T>(object: T): DoubledObject<T>;
export interface Stubber {
thenReturn(...args: any[]): TestDouble;
thenDo(f: Function): TestDouble;
thenThrow(e: Error): TestDouble;
thenResolve(v: any): TestDouble;
thenReject(e: Error): TestDouble;
thenCallback(...args: any[]): TestDouble;
}
export function callback(...args: any[]): void;
export function when(...args: any[]): Stubber;
export interface Matchers {
anything(): any;
isA(type: Function): any;
contains(a: string|any[]|{}): any;
argThat(matcher: Function): any;
not(v: any): any;
captor(): Captor
}
export interface Captor {
capture(): any;
value?: any;
values?: any[];
}
export const matchers: Matchers;
export function replace(path: string, f?: any): any;
export function replace(path: {}, property: string, f?: any): any;
export function reset(): void;
export interface VerificationConfig {
ignoreExtraArgs?: boolean;
times?: number;
}
export function verify(a: any, check?: VerificationConfig): void;
interface Call {
context: {};
args: any[];
}
export interface Explanation {
callCount: number;
calls: Call[];
description: string;
}
export function explain(f: TestDouble): Explanation;