Skip to content

Commit c99ef56

Browse files
author
Brian Ojeda
committed
Add jsdoc initial pass
1 parent bc20362 commit c99ef56

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

index.d.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,33 @@ export interface VerificationConfig {
6161
// general
6262
// ----------------------------------------------------------------------------
6363

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+
*/
6473
export function config(config: TestdoubleConfig): void;
6574

75+
/**
76+
* Reset the state.
77+
*
78+
* @export
79+
*/
6680
export function reset(): void;
6781

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+
*/
6891
export function explain<T>(f: TestDouble<T>): Explanation;
6992

7093

@@ -76,8 +99,21 @@ export function explain<T>(f: TestDouble<T>): Explanation;
7699
// fake: functions
77100
// ----------------------------------------------------------------------------
78101

102+
/**
103+
* Create a fake function.
104+
*
105+
* @param {string} [name] Name of function for better messages.
106+
* @returns {TestDouble<Function>}
107+
*/
79108
declare function functionDouble(name?: string): TestDouble<Function>;
80109

110+
/**
111+
* Create a fake function.
112+
*
113+
* @template T
114+
* @param {T} [name] Name of function to copy.
115+
* @returns {TestDouble<T>}
116+
*/
81117
declare function functionDouble<T>(name?: T): TestDouble<T>;
82118

83119
export { functionDouble as function };
@@ -87,24 +123,98 @@ export { functionDouble as func };
87123
// fake: objects
88124
// ----------------------------------------------------------------------------
89125

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+
*/
90134
export function object<T>(constructor: { new (...args: any[]): T }): DoubledObject<T>;
91135

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+
*/
92144
export function object<Key extends string>(props: Key[]): DoubledObjectWithKey<Key>;
93145

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+
*/
94154
export function object<T>(object: string): DoubledObject<T>;
95155

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+
*/
96164
export function object<T>(object: T): DoubledObject<T>;
97165

98166
//
99167
// stubbing
100168
// ----------------------------------------------------------------------------
101169

170+
171+
/**
172+
* Callback marker.
173+
*
174+
* @export
175+
* @param {...any[]} args
176+
*/
102177
export function callback(...args: any[]): void;
103178

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+
*/
104189
export function replace(path: string, f?: any): any;
105190

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+
*/
106201
export function replace(path: {}, property: string, f?: any): any;
107202

203+
204+
/**
205+
* Stub a specific function call.
206+
*
207+
* @export
208+
* @param {...any[]} args
209+
* @returns {Stubber}
210+
*/
108211
export function when(...args: any[]): Stubber;
109212

213+
/**
214+
* Verify a specific function call to a stubbed function.
215+
*
216+
* @export
217+
* @param {...any[]} args
218+
* @returns {Stubber}
219+
*/
110220
export function verify(a: any, check?: VerificationConfig): void;

0 commit comments

Comments
 (0)