@@ -61,10 +61,33 @@ export interface VerificationConfig {
61
61
// general
62
62
// ----------------------------------------------------------------------------
63
63
64
+ /**
65
+ * Update the configuration. Configuration will perist through the lifetime of
66
+ * of the entire test. If you need to change a configuration property for a
67
+ * single test, you'll need to manage undoing the change yourself (e.g. in
68
+ * beforeEach and afterEach hooks).
69
+ *
70
+ * @export
71
+ * @param {TestdoubleConfig } config
72
+ */
64
73
export function config ( config : TestdoubleConfig ) : void ;
65
74
75
+ /**
76
+ * Reset the state.
77
+ *
78
+ * @export
79
+ */
66
80
export function reset ( ) : void ;
67
81
82
+ /**
83
+ * Takes a test double function as an argument and will describe the current
84
+ * configuration and state of the test double
85
+ *
86
+ * @export
87
+ * @template T
88
+ * @param {TestDouble<T> } f
89
+ * @returns {Explanation }
90
+ */
68
91
export function explain < T > ( f : TestDouble < T > ) : Explanation ;
69
92
70
93
@@ -76,8 +99,21 @@ export function explain<T>(f: TestDouble<T>): Explanation;
76
99
// fake: functions
77
100
// ----------------------------------------------------------------------------
78
101
102
+ /**
103
+ * Create a fake function.
104
+ *
105
+ * @param {string } [name] Name of function for better messages.
106
+ * @returns {TestDouble<Function> }
107
+ */
79
108
declare function functionDouble ( name ?: string ) : TestDouble < Function > ;
80
109
110
+ /**
111
+ * Create a fake function.
112
+ *
113
+ * @template T
114
+ * @param {T } [name] Name of function to copy.
115
+ * @returns {TestDouble<T> }
116
+ */
81
117
declare function functionDouble < T > ( name ?: T ) : TestDouble < T > ;
82
118
83
119
export { functionDouble as function } ;
@@ -87,24 +123,98 @@ export { functionDouble as func };
87
123
// fake: objects
88
124
// ----------------------------------------------------------------------------
89
125
126
+ /**
127
+ * Create a fake object that is deep copy of the given object.
128
+ *
129
+ * @export
130
+ * @template T
131
+ * @param {{ new (...args: any[]): T } } constructor
132
+ * @returns {DoubledObject<T> }
133
+ */
90
134
export function object < T > ( constructor : { new ( ...args : any [ ] ) : T } ) : DoubledObject < T > ;
91
135
136
+ /**
137
+ * Create a fake object that has the given list of properties.
138
+ *
139
+ * @export
140
+ * @template Key
141
+ * @param {Key[] } props Array of properties.
142
+ * @returns {DoubledObjectWithKey<Key> }
143
+ */
92
144
export function object < Key extends string > ( props : Key [ ] ) : DoubledObjectWithKey < Key > ;
93
145
146
+ /**
147
+ * Create a fake empty object that is cast as the generic using a Proxy object.
148
+ *
149
+ * @export
150
+ * @template T
151
+ * @param {T } object Name of object.
152
+ * @returns {DoubledObject<T> }
153
+ */
94
154
export function object < T > ( object : string ) : DoubledObject < T > ;
95
155
156
+ /**
157
+ * Create a fake object that is deep copy of the given object.
158
+ *
159
+ * @export
160
+ * @template T
161
+ * @param {T } object Object to copy.
162
+ * @returns {DoubledObject<T> }
163
+ */
96
164
export function object < T > ( object : T ) : DoubledObject < T > ;
97
165
98
166
//
99
167
// stubbing
100
168
// ----------------------------------------------------------------------------
101
169
170
+
171
+ /**
172
+ * Callback marker.
173
+ *
174
+ * @export
175
+ * @param {...any[] } args
176
+ */
102
177
export function callback ( ...args : any [ ] ) : void ;
103
178
179
+
180
+ /**
181
+ * Swap out real dependenencies with fake one. Intercept calls to `require`
182
+ * that dependency module and ensure your subject is handed a fake instead.
183
+ *
184
+ * @export
185
+ * @param {string } path
186
+ * @param {* } [f]
187
+ * @returns {* }
188
+ */
104
189
export function replace ( path : string , f ?: any ) : any ;
105
190
191
+ /**
192
+ * Swap out real dependenencies with fake one. Reference to the property will
193
+ * be replace it during your test.
194
+ *
195
+ * @export
196
+ * @param {{} } path
197
+ * @param {string } property
198
+ * @param {* } [f]
199
+ * @returns {* }
200
+ */
106
201
export function replace ( path : { } , property : string , f ?: any ) : any ;
107
202
203
+
204
+ /**
205
+ * Stub a specific function call.
206
+ *
207
+ * @export
208
+ * @param {...any[] } args
209
+ * @returns {Stubber }
210
+ */
108
211
export function when ( ...args : any [ ] ) : Stubber ;
109
212
213
+ /**
214
+ * Verify a specific function call to a stubbed function.
215
+ *
216
+ * @export
217
+ * @param {...any[] } args
218
+ * @returns {Stubber }
219
+ */
110
220
export function verify ( a : any , check ?: VerificationConfig ) : void ;
0 commit comments